membphis commented on code in PR #11840:
URL: https://github.com/apache/apisix/pull/11840#discussion_r1942405999
##########
apisix/consumer.lua:
##########
@@ -80,7 +85,53 @@ local function filter_consumers_list(data_list)
return list
end
-local function plugin_consumer()
+local plugin_consumer
+do
+ local consumers_id_lrucache = core.lrucache.new({
+ count = consumers_count_for_lrucache
+ })
+
+local function construct_consumer_data(val, plugin_config)
+ -- if the val is a Consumer, clone it to the local consumer;
+ -- if the val is a Credential, to get the Consumer by consumer_name and
then clone
+ -- it to the local consumer.
+ local consumer
+ if is_credential_etcd_key(val.key) then
+ local consumer_name =
get_consumer_name_from_credential_etcd_key(val.key)
+ local the_consumer = consumers:get(consumer_name)
+ if the_consumer and the_consumer.value then
+ consumer = core.table.clone(the_consumer.value)
+ consumer.modifiedIndex = the_consumer.modifiedIndex
+ consumer.credential_id = get_credential_id_from_etcd_key(val.key)
+ else
+ -- Normally wouldn't get here:
+ -- it should belong to a consumer for any credential.
+ core.log.error("failed to get the consumer for the credential,",
+ " a wild credential has appeared!",
+ " credential key: ", val.key, ", consumer name: ",
consumer_name)
+ return nil, "failed to get the consumer for the credential"
+ end
+ else
+ consumer = core.table.clone(val.value)
+ consumer.modifiedIndex = val.modifiedIndex
Review Comment:
I think `consumer.modifiedIndex` equal `val.modifiedIndex` after we called
`core.table.clone(val.value)1`
We do not need to set this value again
Only comments should be enough.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]