spacewander commented on code in PR #9012:
URL: https://github.com/apache/apisix/pull/9012#discussion_r1131890899


##########
docs/en/latest/get-data-planes-from-etcd.md:
##########
@@ -0,0 +1,97 @@
+---
+id: get-data-planes-from-etcd
+title: Get data planes from etcd
+keywords:
+  - API gateway
+  - Apache APISIX
+description: Get data planes from etcd
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+To query all data planes information from etcd, we move `server-info` plugin 
into the APISIX core, and use it to report data plane information.
+
+The data plane information keeps the same format of `server-info` plugin 
output:
+
+https://apisix.apache.org/en/docs/apisix/plugins/server-info/
+
+## Admin API to query data planes

Review Comment:
   We should move this into Admin API doc: 
https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md



##########
apisix/plugin.lua:
##########
@@ -746,6 +746,10 @@ function _M.init_worker()
     -- see https://github.com/apache/apisix/issues/3286
     _M.load()
 
+    if is_http then
+        require("apisix.plugins.server-info").init_worker()

Review Comment:
   `require("apisix.plugins.xxx")` will make the module import complex. We 
should use a separate file to hold the functons.



##########
docs/en/latest/get-data-planes-from-etcd.md:
##########
@@ -0,0 +1,97 @@
+---
+id: get-data-planes-from-etcd
+title: Get data planes from etcd
+keywords:
+  - API gateway
+  - Apache APISIX
+description: Get data planes from etcd
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+To query all data planes information from etcd, we move `server-info` plugin 
into the APISIX core, and use it to report data plane information.
+
+The data plane information keeps the same format of `server-info` plugin 
output:
+
+https://apisix.apache.org/en/docs/apisix/plugins/server-info/

Review Comment:
   Better to move the relative content in server-info out to here. As that 
plugin is not so useful now.



##########
apisix/admin/init.lua:
##########
@@ -237,6 +237,40 @@ local function run()
 end
 
 
+local function get_data_planes()
+    local key = "/data_plane/server_info"
+    local is_dir = true
+    local uri_segs = core.utils.split_uri(ngx.var.uri)
+    local id = uri_segs[5]
+    if id then
+        key = key .. "/" .. id
+        is_dir = false
+    end
+
+    local etcd_cli, prefix = core.etcd.get_etcd_cli()
+    key = prefix .. key
+    local res, err = etcd_cli:readdir(key)
+    if err then
+        core.log.warn("failed to do etcd readdir: ", err)
+        core.response.exit(502, {error_msg =

Review Comment:
   Like 
https://github.com/apache/apisix/blob/09cc4946bc051452960975b4dd7436a2497df346/apisix/admin/resource.lua#L122,
 we usually return 503 for this case



##########
apisix/plugins/server-info.lua:
##########
@@ -307,8 +307,8 @@ function _M.init()
 end
 
 
-function _M.destroy()
-    timers.unregister_timer("plugin#server-info", true)
+function _M.init()
+    core.log.warn("server-info plugin was moved into APISIX core, no need to 
enable it explicitly")

Review Comment:
   We should update server-info plugin's doc too.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to