This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 36974604e chore: don't implement "server_version" twice (#8131)
36974604e is described below

commit 36974604eef6645c8dd59e630a523a687819fdb5
Author: 罗泽轩 <spacewander...@gmail.com>
AuthorDate: Fri Oct 21 13:41:02 2022 +0800

    chore: don't implement "server_version" twice (#8131)
---
 apisix/core/config_etcd.lua | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua
index e432b05d9..80d6d23e2 100644
--- a/apisix/core/config_etcd.lua
+++ b/apisix/core/config_etcd.lua
@@ -716,32 +716,17 @@ function _M.fetch_created_obj(key)
 end
 
 
-local function read_etcd_version(etcd_cli)
-    if not etcd_cli then
-        return nil, "not inited"
-    end
-
-    local data, err = etcd_cli:version()
-    if not data then
-        return nil, err
-    end
-
-    local body = data.body
-    if type(body) ~= "table" then
-        return nil, "failed to read response body when try to fetch etcd "
-                    .. "version"
-    end
-
-    return body
-end
-
-
 function _M.server_version(self)
     if not self.running then
         return nil, "stopped"
     end
 
-    return read_etcd_version(self.etcd_cli)
+    local res, err = etcd_apisix.server_version()
+    if not res then
+        return nil, err
+    end
+
+    return res.body
 end
 
 

Reply via email to