You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/11/23 04:07:27 UTC

[GitHub] [apisix] soulbird opened a new pull request, #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

soulbird opened a new pull request, #8379:
URL: https://github.com/apache/apisix/pull/8379

   ### Description
   
   <!-- Please include a summary of the change and which issue is fixed. -->
   <!-- Please also include relevant motivation and context. -->
   
   Fixes # (issue)
   
   ### Checklist
   
   - [ ] I have explained the need for this PR and the problem it solves
   - [ ] I have explained the changes or the new features added to this PR
   - [ ] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [ ] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] membphis commented on pull request #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

Posted by GitBox <gi...@apache.org>.
membphis commented on PR #8379:
URL: https://github.com/apache/apisix/pull/8379#issuecomment-1324674372

   I like this PR which removed a lot of code


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] soulbird commented on a diff in pull request #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

Posted by GitBox <gi...@apache.org>.
soulbird commented on code in PR #8379:
URL: https://github.com/apache/apisix/pull/8379#discussion_r1030056237


##########
apisix/consumer.lua:
##########
@@ -94,6 +97,26 @@ function _M.consumers()
 end
 
 
+local function create_consume_cache(consumers_conf, key_attr, consumer_names)
+    core.table.clear(consumer_names)
+
+    for _, consumer in ipairs(consumers_conf.nodes) do
+        core.log.info("consumer node: ", core.json.delay_encode(consumer))
+        consumer_names[consumer.auth_conf[key_attr]] = consumer
+    end
+
+    return consumer_names
+end
+
+
+function _M.consumers_kv(plugin_name, consumer_conf, key_attr, consumer_names)

Review Comment:
   Seems unnecessary, I'll use a temporary consumer_names table



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on a diff in pull request #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #8379:
URL: https://github.com/apache/apisix/pull/8379#discussion_r1030034730


##########
apisix/consumer.lua:
##########
@@ -94,6 +97,26 @@ function _M.consumers()
 end
 
 
+local function create_consume_cache(consumers_conf, key_attr, consumer_names)
+    core.table.clear(consumer_names)
+
+    for _, consumer in ipairs(consumers_conf.nodes) do
+        core.log.info("consumer node: ", core.json.delay_encode(consumer))
+        consumer_names[consumer.auth_conf[key_attr]] = consumer
+    end
+
+    return consumer_names
+end
+
+
+function _M.consumers_kv(plugin_name, consumer_conf, key_attr, consumer_names)

Review Comment:
   Why do we need to pass a consumer_names and fill it?



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on a diff in pull request #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #8379:
URL: https://github.com/apache/apisix/pull/8379#discussion_r1030097568


##########
apisix/plugins/jwt-auth.lua:
##########
@@ -435,8 +412,7 @@ function _M.rewrite(conf, ctx)
         return 401, {message = "Missing related consumer"}
     end
 
-    local consumers = lrucache("consumers_key", consumer_conf.conf_version,
-        create_consume_cache, consumer_conf)
+    local consumers = consumer_mod.consumers_kv(plugin_name, consumer_conf, "key")

Review Comment:
   Should be "user_key"?



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] soulbird commented on a diff in pull request #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

Posted by GitBox <gi...@apache.org>.
soulbird commented on code in PR #8379:
URL: https://github.com/apache/apisix/pull/8379#discussion_r1030099319


##########
apisix/plugins/jwt-auth.lua:
##########
@@ -435,8 +412,7 @@ function _M.rewrite(conf, ctx)
         return 401, {message = "Missing related consumer"}
     end
 
-    local consumers = lrucache("consumers_key", consumer_conf.conf_version,
-        create_consume_cache, consumer_conf)
+    local consumers = consumer_mod.consumers_kv(plugin_name, consumer_conf, "key")

Review Comment:
   No, look: https://github.com/apache/apisix/blob/master/apisix/plugins/jwt-auth.lua#L149
   ```
   consumer_names[consumer.auth_conf.key] = consumer
   ```



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander merged pull request #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

Posted by GitBox <gi...@apache.org>.
spacewander merged PR #8379:
URL: https://github.com/apache/apisix/pull/8379


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] tzssangglass commented on pull request #8379: refactor(consumer): expose create_consume_cache so that we can preprocess the consumer conf

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on PR #8379:
URL: https://github.com/apache/apisix/pull/8379#issuecomment-1324635511

   LGTM


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org