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 11:54:28 UTC

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

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