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/02/14 03:23:24 UTC

[GitHub] [apisix] tzssangglass commented on a change in pull request #6202: feat: use keepalive in server-info plugin

tzssangglass commented on a change in pull request #6202:
URL: https://github.com/apache/apisix/pull/6202#discussion_r805475302



##########
File path: apisix/plugins/server-info.lua
##########
@@ -132,51 +125,107 @@ local function get_server_info()
 end
 
 
+local function set(key,value,ttl, modified_index)

Review comment:
       ```suggestion
   local function set(key, value, ttl, modified_index)
   ```

##########
File path: apisix/plugins/server-info.lua
##########
@@ -132,51 +125,107 @@ local function get_server_info()
 end
 
 
+local function set(key,value,ttl, modified_index)
+    local res_new, err = core.etcd.atomic_set(key, value, ttl, modified_index)
+    if not res_new then
+        core.log.error("failed to set server_info: ", err)
+        return 503, {error_msg = err}
+    end
+
+    lease_id = res_new.body.lease_id
+
+    -- set or update lease_id
+    local ok, err = internal_status:set("lease_id", lease_id)
+    if not ok then
+        core.log.error("failed to set lease_id to shdict: ", err)
+        return 503, {error_msg = err}
+    end
+
+    return 200, nil
+end

Review comment:
       It looks like the two steps should be in sync, and we can use lock in the next PR to keep them in sync.

##########
File path: apisix/plugins/server-info.lua
##########
@@ -132,51 +125,107 @@ local function get_server_info()
 end
 
 
+local function set(key,value,ttl, modified_index)
+    local res_new, err = core.etcd.atomic_set(key, value, ttl, modified_index)
+    if not res_new then
+        core.log.error("failed to set server_info: ", err)
+        return 503, {error_msg = err}
+    end
+
+    lease_id = res_new.body.lease_id

Review comment:
       should we check if `lease_id` is not nil?




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