AlexStocks commented on code in PR #1055:
URL: https://github.com/apache/dubbo-go-samples/pull/1055#discussion_r2944376512


##########
generic/go-client/cmd/client.go:
##########
@@ -24,64 +24,58 @@ import (
 )
 
 import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/client"
        "dubbo.apache.org/dubbo-go/v3/common/constant"
-       "dubbo.apache.org/dubbo-go/v3/config"
-       "dubbo.apache.org/dubbo-go/v3/config/generic"
+       "dubbo.apache.org/dubbo-go/v3/filter/generic"
        _ "dubbo.apache.org/dubbo-go/v3/imports"
 
        hessian "github.com/apache/dubbo-go-hessian2"
 
        "github.com/dubbogo/gost/log/logger"
-
-       tpconst "github.com/dubbogo/triple/pkg/common/constant"
 )
 
 import (
        "github.com/apache/dubbo-go-samples/generic/go-client/pkg"
 )
 
 const (
-       AppName          = "generic-go-client"
-       RegistryID       = "zk"
-       ZookeeperAddress = "127.0.0.1:2181"
-       UserProvider     = "org.apache.dubbo.samples.UserProvider"
-       ServiceVersion   = "1.0.0"
+       DirectServerURL = "tri://127.0.0.1:50052"
+       UserProvider    = "org.apache.dubbo.samples.UserProvider"
+       ServiceVersion  = "1.0.0"
+       ServiceGroup    = "triple"
 )
 
 func main() {
        hessian.RegisterPOJO(&pkg.User{})
 
-       rootConfig := config.NewRootConfigBuilder().
-               SetApplication(
-                       config.NewApplicationConfigBuilder().
-                               SetName(AppName).
-                               Build(),
-               ).
-               AddRegistry(RegistryID, &config.RegistryConfig{
-                       Protocol: "zookeeper",
-                       Address:  ZookeeperAddress,
-               }).
-               Build()
-       if err := config.Load(config.WithRootConfig(rootConfig)); err != nil {
+       ins, err := dubbo.NewInstance(

Review Comment:
   `client.WithClientURL` 在 Client 级别设置直连 URL,会让这个 Client 创建的所有 GenericService 
都走直连,而不仅仅是当前这个服务。对于 sample 来说目前没问题,但容易让用户误以为这是新 API 的标准用法。
   
   如果 `cli.NewGenericService` 支持 `client.WithURL` 选项,建议改成在 NewGenericService 
层面设置,职责更清晰:
   ```go
   genericService, err := cli.NewGenericService(
       UserProvider,
       client.WithURL(DirectServerURL),
       client.WithVersion(ServiceVersion),
       client.WithGroup(ServiceGroup),
   )
   ```



##########
generic/java-server/src/main/java/org/apache/dubbo/samples/ApiProvider.java:
##########
@@ -47,9 +46,8 @@ public static void main(String[] args) throws 
InterruptedException {
         tripleService.setVersion(SERVICE_VERSION);
         tripleService.setProtocol(new ProtocolConfig("tri", TRIPLE_PORT));
 
-        // Register provider to ZooKeeper
-        RegistryConfig registryConfig = new RegistryConfig();
-        registryConfig.setAddress(ZOOKEEPER_ADDRESS);
+        // No registry: expose directly on the configured ports

Review Comment:
   `new RegistryConfig("N/A")` 是 Dubbo Java 
关闭注册中心的惯用写法,但这里直接替换没有注释,读者很容易以为是占位符或者遗漏了真实地址。
   
   建议加一行注释说明意图,比如:
   ```java
   // "N/A" disables registry; provider is exposed directly on the configured 
port
   RegistryConfig registryConfig = new RegistryConfig("N/A");
   ```



##########
generic/java-server/src/main/java/org/apache/dubbo/samples/ApiProvider.java:
##########
@@ -25,10 +25,9 @@
 import java.util.concurrent.CountDownLatch;
 
 public class ApiProvider {

Review Comment:
   行尾有多余空格,删掉。
   ```java
   private static final int DUBBO_PORT = 20000;
   ```



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