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 2020/11/13 08:17:21 UTC

[GitHub] [apisix] spacewander opened a new pull request #2740: feat: generate create/update_time automatically

spacewander opened a new pull request #2740:
URL: https://github.com/apache/apisix/pull/2740


   Close #2654.
   
   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   * [ ] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible?
   


----------------------------------------------------------------
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.

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



[GitHub] [apisix] spacewander commented on a change in pull request #2740: feat: generate create/update_time automatically

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #2740:
URL: https://github.com/apache/apisix/pull/2740#discussion_r523703474



##########
File path: apisix/admin/consumers.lua
##########
@@ -76,6 +77,19 @@ function _M.put(consumer_name, conf)
 
     local key = "/consumers/" .. consumer_name
     core.log.info("key: ", key)
+
+    local res, err = core.etcd.get(key)
+    if not res or (res.status ~= 200 and res.status ~= 404) then
+        core.log.error("failed to get consumer[", key, "] from etcd: ", err or res.status)
+        return 500, {error_msg = err}
+    end
+
+    if res.status == 404 then
+        utils.inject_timestamp(conf)
+    else
+        utils.inject_timestamp(conf, res.body)
+    end
+

Review comment:
       @nic-chen 
   Changed.




----------------------------------------------------------------
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.

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



[GitHub] [apisix] nic-chen commented on a change in pull request #2740: feat: generate create/update_time automatically

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #2740:
URL: https://github.com/apache/apisix/pull/2740#discussion_r522903919



##########
File path: apisix/admin/consumers.lua
##########
@@ -76,6 +77,19 @@ function _M.put(consumer_name, conf)
 
     local key = "/consumers/" .. consumer_name
     core.log.info("key: ", key)
+
+    local res, err = core.etcd.get(key)
+    if not res or (res.status ~= 200 and res.status ~= 404) then
+        core.log.error("failed to get consumer[", key, "] from etcd: ", err or res.status)
+        return 500, {error_msg = err}
+    end
+
+    if res.status == 404 then
+        utils.inject_timestamp(conf)
+    else
+        utils.inject_timestamp(conf, res.body)
+    end
+

Review comment:
       I think we could put them in a function too,what do you think?




----------------------------------------------------------------
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.

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



[GitHub] [apisix] moonming merged pull request #2740: feat: generate create/update_time automatically

Posted by GitBox <gi...@apache.org>.
moonming merged pull request #2740:
URL: https://github.com/apache/apisix/pull/2740


   


----------------------------------------------------------------
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.

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