Copilot commented on code in PR #1008:
URL: https://github.com/apache/dubbo-go-samples/pull/1008#discussion_r2638199578


##########
config_center/zookeeper/README.md:
##########
@@ -59,14 +64,39 @@ if err := srv.Serve(); err != nil {
 }
 ```
 
-### Run client
+### Run go server
+
+```
+$ go run ./go-server/cmd/main.go
+```
 
-```shell
+### Run go client
+
+```
 $ go run ./go-client/cmd/main.go
 ```
+### Before run java server/client
+```
+mvn clean compile
+```
+### Run java server(windows)

Review Comment:
   Inconsistent capitalization: "server" and "client" should be capitalized in 
the section header for consistency with "Run go server" header. Should be "Run 
java server(windows)" -> "Run Java server (Windows)" for better consistency.



##########
config_center/nacos/java-client/src/main/java/org/example/client/NacosJavaClient.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+package org.example.client;
+
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.config.ConfigService;
+import greet.GreetService;
+import greet.GreetRequest;
+import greet.GreetResponse;
+import org.apache.dubbo.config.ConfigCenterConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import java.util.Properties;
+
+public class NacosJavaClient {
+    // Nacos server address (used as config center)
+    private static final String NACOS_ADDR = "127.0.0.1:8848";
+    // Zookeeper address (used as registry)
+    private static final String ZK_ADDR = "127.0.0.1:2181";
+    // DataId used in Nacos config center
+    private static final String DATA_ID = 
"dubbo-go-samples-configcenter-nacos-java-client";
+    // Nacos group
+    private static final String GROUP = "dubbo";
+    // Configuration content pushed to Nacos config center
+    // Dubbo will load these as consumer / registry / protocol configs
+    private static final String CONFIG_CONTENT =
+            "dubbo.application.name=dubbo-java-consumer\n" +
+                    "dubbo.registry.address=zookeeper://" + ZK_ADDR + "\n" +
+                    "dubbo.protocol.name=tri\n" +
+                    "dubbo.consumer.timeout=10000\n";
+
+    public static void main(String[] args) throws Exception {
+        //Publish Dubbo config to Nacos config center
+        Properties properties = new Properties();
+        properties.put("serverAddr", NACOS_ADDR);
+        ConfigService configService = 
NacosFactory.createConfigService(properties);
+        boolean success = configService.publishConfig(DATA_ID, GROUP, 
CONFIG_CONTENT);
+        if (success) {
+            System.out.println(" Succeed to publish config to Nacos, DATA_ID= 
" + DATA_ID);
+        } else {
+            System.err.println(" Failed to publish config to Nacos ");
+        }
+
+
+        ConfigCenterConfig configCenter = new ConfigCenterConfig();
+        configCenter.setAddress("nacos://" + NACOS_ADDR);
+        configCenter.setConfigFile(DATA_ID);
+        configCenter.setGroup(GROUP);
+
+        // Create reference config, only bind interface here
+        ReferenceConfig<GreetService> reference = new ReferenceConfig<>();
+        reference.setInterface(GreetService.class);
+
+        // Create reference config, only bind interface here

Review Comment:
   Duplicate comment: the same comment "Create reference config, only bind 
interface here" appears on both line 65 and line 69. The second occurrence 
should be removed or replaced with a more accurate description like "Start 
DubboBootstrap with config center and reference".
   ```suggestion
           // Start DubboBootstrap with config center and reference
   ```



##########
config_center/zookeeper/README.md:
##########
@@ -59,14 +64,39 @@ if err := srv.Serve(); err != nil {
 }
 ```
 
-### Run client
+### Run go server
+
+```
+$ go run ./go-server/cmd/main.go
+```
 
-```shell
+### Run go client
+
+```
 $ go run ./go-client/cmd/main.go
 ```
+### Before run java server/client
+```
+mvn clean compile
+```
+### Run java server(windows)
+```
+mvn -pl java-server exec:java 
"-Dexec.mainClass=org.example.server.ZookeeperJavaServer" 
+```
+
+### Run java client(windows)

Review Comment:
   Inconsistent capitalization: "client" should be capitalized in the section 
header for consistency with "Run go client" header. Should be "Run java 
client(windows)" -> "Run Java client (Windows)" for better consistency.
   ```suggestion
   ### Run Java client (Windows)
   ```



##########
config_center/nacos/java-server/src/main/java/org/example/server/NacosJavaServer.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+package org.example.server;
+
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.config.ConfigService;
+import greet.GreetService;
+import greet.GreetRequest;
+import greet.GreetResponse;
+import org.apache.dubbo.config.ConfigCenterConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import java.util.Properties;
+
+
+public class NacosJavaServer{
+    // Nacos server address (used as config center)
+    private static final String NACOS_ADDR = "127.0.0.1:8848";
+    // Zookeeper address (used as registry)
+    private static final String ZK_ADDR = "127.0.0.1:2181";
+    // DataId used in Nacos config center
+    private static final String DATA_ID = 
"dubbo-go-samples-configcenter-nacos-java-server";
+    // Nacos group
+    private static final String GROUP = "dubbo";
+    // Configuration content pushed to Nacos config center
+    // Dubbo will load these as application / registry / protocol configs
+    private static final String CONFIG_CONTENT =
+            "dubbo.application.name=dubbo-java-provider\n" +
+                    "dubbo.registry.address=zookeeper://" + ZK_ADDR + "\n" +
+                    "dubbo.protocol.name=tri\n" +
+                    "dubbo.protocol.port=50051\n";
+    public static void main(String[] args) throws Exception {
+        // Publish Dubbo config to Nacos config center
+        Properties properties = new Properties();
+        properties.put("serverAddr", NACOS_ADDR);
+        ConfigService configService = 
NacosFactory.createConfigService(properties);
+        boolean success=configService.publishConfig(DATA_ID, GROUP, 
CONFIG_CONTENT);
+        if (success) {
+            System.out.println(" Succeed to publish config to Nacos, DATA_ID= 
"+DATA_ID);

Review Comment:
   Grammatical error: "Succeed" should be "Succeeded" (past tense) in the 
success message. The verb form should match the action that has already 
completed.
   ```suggestion
               System.out.println(" Succeeded to publish config to Nacos, 
DATA_ID= "+DATA_ID);
   ```



##########
config_center/nacos/java-server/pom.xml:
##########
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.example</groupId>
+        <artifactId>nacos-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>java-server</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-netty-shaded</artifactId>
+            <version>1.75.0</version>

Review Comment:
   The grpc-netty-shaded version is hardcoded to 1.75.0, which is inconsistent 
with the parent POM that defines grpc.version as 1.60.0. This should use the 
property ${grpc.version} instead to maintain consistency across the project.
   ```suggestion
               <version>${grpc.version}</version>
   ```



##########
config_center/nacos/java-server/src/main/java/org/example/server/NacosJavaServer.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+package org.example.server;
+
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.config.ConfigService;
+import greet.GreetService;
+import greet.GreetRequest;
+import greet.GreetResponse;
+import org.apache.dubbo.config.ConfigCenterConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import java.util.Properties;
+
+
+public class NacosJavaServer{
+    // Nacos server address (used as config center)
+    private static final String NACOS_ADDR = "127.0.0.1:8848";
+    // Zookeeper address (used as registry)
+    private static final String ZK_ADDR = "127.0.0.1:2181";
+    // DataId used in Nacos config center
+    private static final String DATA_ID = 
"dubbo-go-samples-configcenter-nacos-java-server";
+    // Nacos group
+    private static final String GROUP = "dubbo";
+    // Configuration content pushed to Nacos config center
+    // Dubbo will load these as application / registry / protocol configs
+    private static final String CONFIG_CONTENT =
+            "dubbo.application.name=dubbo-java-provider\n" +
+                    "dubbo.registry.address=zookeeper://" + ZK_ADDR + "\n" +
+                    "dubbo.protocol.name=tri\n" +
+                    "dubbo.protocol.port=50051\n";
+    public static void main(String[] args) throws Exception {
+        // Publish Dubbo config to Nacos config center
+        Properties properties = new Properties();
+        properties.put("serverAddr", NACOS_ADDR);
+        ConfigService configService = 
NacosFactory.createConfigService(properties);
+        boolean success=configService.publishConfig(DATA_ID, GROUP, 
CONFIG_CONTENT);

Review Comment:
   Missing space after the equals sign. Should be "success = 
configService.publishConfig" for proper code formatting and readability.
   ```suggestion
           boolean success = configService.publishConfig(DATA_ID, GROUP, 
CONFIG_CONTENT);
   ```



##########
config_center/zookeeper/README.md:
##########
@@ -22,10 +26,11 @@ dubbo:
   provider:
     services:
       GreeterProvider:
-        interface: com.apache.dubbo.sample.basic.IGreeter
+        interface: greet.GreetService
 ```
 
 Open the local zookeeper client to see if the configuration is successful

Review Comment:
   Missing punctuation: the sentence should end with a period. Should be "Open 
the local zookeeper client to see if the configuration is successful."
   ```suggestion
   Open the local zookeeper client to see if the configuration is successful.
   ```



##########
config_center/nacos/README.md:
##########
@@ -59,14 +65,39 @@ if err := srv.Serve(); err != nil {
 }
 ```
 
-### Run client
+### Run go server
 
-```shell
+```
+$ go run ./go-server/cmd/main.go
+```
+
+### Run go client
+
+```
 $ go run ./go-client/cmd/main.go
 ```
+### Before run java server/client
+```
+mvn clean compile
+```
+### Run java server(windows)

Review Comment:
   Inconsistent capitalization: "server" and "client" should be capitalized in 
the section headers for consistency with "Run go server" and "Run go client" 
headers. Should be "Run java server(windows)" -> "Run java server (windows)" or 
"Run Java server (Windows)" for better consistency.



##########
config_center/nacos/java-client/src/main/java/org/example/client/NacosJavaClient.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+package org.example.client;
+
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.config.ConfigService;
+import greet.GreetService;
+import greet.GreetRequest;
+import greet.GreetResponse;
+import org.apache.dubbo.config.ConfigCenterConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import java.util.Properties;
+
+public class NacosJavaClient {
+    // Nacos server address (used as config center)
+    private static final String NACOS_ADDR = "127.0.0.1:8848";
+    // Zookeeper address (used as registry)
+    private static final String ZK_ADDR = "127.0.0.1:2181";
+    // DataId used in Nacos config center
+    private static final String DATA_ID = 
"dubbo-go-samples-configcenter-nacos-java-client";
+    // Nacos group
+    private static final String GROUP = "dubbo";
+    // Configuration content pushed to Nacos config center
+    // Dubbo will load these as consumer / registry / protocol configs
+    private static final String CONFIG_CONTENT =
+            "dubbo.application.name=dubbo-java-consumer\n" +
+                    "dubbo.registry.address=zookeeper://" + ZK_ADDR + "\n" +
+                    "dubbo.protocol.name=tri\n" +
+                    "dubbo.consumer.timeout=10000\n";
+
+    public static void main(String[] args) throws Exception {
+        //Publish Dubbo config to Nacos config center
+        Properties properties = new Properties();
+        properties.put("serverAddr", NACOS_ADDR);
+        ConfigService configService = 
NacosFactory.createConfigService(properties);
+        boolean success = configService.publishConfig(DATA_ID, GROUP, 
CONFIG_CONTENT);
+        if (success) {
+            System.out.println(" Succeed to publish config to Nacos, DATA_ID= 
" + DATA_ID);

Review Comment:
   Grammatical error: "Succeed" should be "Succeeded" (past tense) in the 
success message. The verb form should match the action that has already 
completed.
   ```suggestion
               System.out.println(" Succeeded to publish config to Nacos, 
DATA_ID= " + DATA_ID);
   ```



##########
config_center/nacos/README.md:
##########
@@ -59,14 +65,39 @@ if err := srv.Serve(); err != nil {
 }
 ```
 
-### Run client
+### Run go server
 
-```shell
+```
+$ go run ./go-server/cmd/main.go
+```
+
+### Run go client
+
+```
 $ go run ./go-client/cmd/main.go
 ```
+### Before run java server/client
+```
+mvn clean compile
+```
+### Run java server(windows)
+```
+mvn -pl java-server exec:java 
"-Dexec.mainClass=org.example.server.NacosJavaServer" 
+```
+
+### Run java client(windows)

Review Comment:
   Inconsistent capitalization: "client" should be capitalized in the section 
header for consistency with "Run go client" header. Should be "Run java 
client(windows)" -> "Run Java client (Windows)" for better consistency.
   ```suggestion
   ### Run Java client (Windows)
   ```



##########
config_center/nacos/README.md:
##########
@@ -22,10 +27,11 @@ dubbo:
   provider:
     services:
       GreeterProvider:
-        interface: com.apache.dubbo.sample.basic.IGreeter
+        interface: greet.GreetService
 ```
 
 Open `https://localhost:8848/nacos/` with browser, make sure the relevant 
configuration is already in place in nacos.

Review Comment:
   Missing punctuation: the sentence should end with a period. Should be "Open 
`https://localhost:8848/nacos/` with browser, make sure the relevant 
configuration is already in place in nacos."



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