spacewander commented on a change in pull request #3742:
URL: https://github.com/apache/apisix/pull/3742#discussion_r587213009
##########
File path: apisix/control/router.lua
##########
@@ -66,6 +68,38 @@ function fetch_control_api_router()
end
end
+ local discovery_type =
require("apisix.core.config_local").local_conf().discovery
+ if discovery_type then
+ local discovery = require("apisix.discovery.init").discovery
+ local dump_apis = {}
+ for key, _ in pairs(discovery_type) do
Review comment:
It seems we can use `for key, dis_mod in pairs(discovery) do` directly?
##########
File path: docs/en/latest/discovery.md
##########
@@ -66,7 +67,9 @@ It is very easy for APISIX to extend the discovery client,
the basic steps are a
2. Implement the `_M. init_worker()` function for initialization and the `_M.
nodes(service_name)` function for obtaining the list of service instance nodes;
-3. Convert the registry data into data in APISIX;
+3. If you need the discovery module to export the debugging information
online, implement the `_M. dump_data()` function;
Review comment:
Style: extra space before `dump_data`.
##########
File path: t/control/discovery.t
##########
@@ -0,0 +1,102 @@
+#
+# 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.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+no_shuffle();
+log_level("info");
+
+
+our $yaml_config = <<_EOC_;
+apisix:
+ enable_control: true
+ node_listen: 1984
+ config_center: yaml
+ enable_admin: false
+
+discovery:
+ eureka:
+ host:
+ - "http://127.0.0.1:8761"
+ prefix: "/eureka/"
+ fetch_interval: 10
+ weight: 80
+ timeout:
+ connect: 1500
+ send: 1500
+ read: 1500
+ consul_kv:
+ servers:
+ - "http://127.0.0.1:8500"
+ - "http://127.0.0.1:8600"
+ dns:
+ servers:
+ - "127.0.0.1:1053"
+_EOC_
+
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: test consul_kv dump_data api
+--- yaml_config eval: $::yaml_config
+--- request
+GET /v1/discovery/consul_kv/dump
+--- error_code: 200
+--- response_body_unlike
+^{}$
Review comment:
Can we check part of the content in this way:
https://github.com/apache/apisix/blob/8e3fd226714d0a733b87aac33f64fe97e77d3785/t/control/schema.t#L45
##########
File path: t/control/discovery.t
##########
@@ -0,0 +1,102 @@
+#
+# 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.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+no_shuffle();
+log_level("info");
+
+
+our $yaml_config = <<_EOC_;
+apisix:
+ enable_control: true
+ node_listen: 1984
+ config_center: yaml
+ enable_admin: false
+
+discovery:
+ eureka:
+ host:
+ - "http://127.0.0.1:8761"
+ prefix: "/eureka/"
+ fetch_interval: 10
+ weight: 80
+ timeout:
+ connect: 1500
+ send: 1500
+ read: 1500
+ consul_kv:
+ servers:
+ - "http://127.0.0.1:8500"
+ - "http://127.0.0.1:8600"
+ dns:
+ servers:
+ - "127.0.0.1:1053"
+_EOC_
+
+
+run_tests();
+
+__DATA__
+
+=== TEST 1: test consul_kv dump_data api
+--- yaml_config eval: $::yaml_config
+--- request
+GET /v1/discovery/consul_kv/dump
+--- error_code: 200
+--- response_body_unlike
+^{}$
+
+
+
+=== TEST 2: test eureka dump_data api
+--- yaml_config eval: $::yaml_config
+--- request
+GET /v1/discovery/eureka/dump
+--- error_code: 200
+--- response_body_unlike
+^{}$
Review comment:
ditto
----------------------------------------------------------------
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:
[email protected]