serverglen commented on code in PR #1922:
URL: https://github.com/apache/incubator-brpc/pull/1922#discussion_r966811710


##########
src/brpc/periodic_naming_service.h:
##########
@@ -29,6 +29,8 @@ class PeriodicNamingService : public NamingService {
     virtual int GetServers(const char *service_name,
                            std::vector<ServerNode>* servers) = 0;
     
+    virtual long GetSleepMilliseconds() const;

Review Comment:
   没必要long吧,int我理解就够了



##########
src/brpc/policy/nacos_naming_service.cpp:
##########
@@ -0,0 +1,287 @@
+// 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.
+
+
+#include "nacos_naming_service.h"
+
+#include <gflags/gflags.h>
+
+#include <set>
+
+#include "brpc/http_status_code.h"
+#include "brpc/log.h"
+#include "butil/iobuf.h"
+#include "butil/logging.h"
+#include "butil/third_party/rapidjson/document.h"
+
+namespace brpc {
+namespace policy {
+
+DEFINE_string(nacos_address, "http://127.0.0.1:8848";,
+              "The query string of request nacos for discovering service.");
+DEFINE_string(nacos_service_discovery_path, "/nacos/v1/ns/instance/list",
+              "The url path for discovering service.");
+DEFINE_string(nacos_service_auth_path, "/nacos/v1/auth/login",
+              "The url path for authentiction.");
+DEFINE_int32(nacos_connect_timeout_ms, 200,
+             "Timeout for creating connections to nacos in milliseconds");
+DEFINE_string(nacos_username, "", "nacos username");
+DEFINE_string(nacos_password, "", "nacos password");
+
+int NacosNamingService::Connect() {
+    ChannelOptions opt;
+    opt.protocol = PROTOCOL_HTTP;
+    opt.connect_timeout_ms = FLAGS_nacos_connect_timeout_ms;
+    const int ret = _channel.Init(FLAGS_nacos_address.c_str(), "rr", &opt);

Review Comment:
   建议load_balancer也可以通过gflags方式进行设计



##########
src/brpc/periodic_naming_service.cpp:
##########
@@ -47,7 +51,7 @@ int PeriodicNamingService::RunNamingService(
             actions->ResetServers(servers);
         }
 
-        if (bthread_usleep(std::max(FLAGS_ns_access_interval, 1) * 1000000L) < 
0) {
+        if (bthread_usleep(GetSleepMilliseconds() * 1000L) < 0) {

Review Comment:
   GetNamingServiceAccessInterval



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to