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


##########
generic/java-server/src/main/java/org/apache/dubbo/samples/ApiProvider.java:
##########
@@ -28,6 +28,7 @@ public class ApiProvider {
     private static final int DUBBO_PORT = 20000;
     private static final int TRIPLE_PORT = 50052;
     private static final String SERVICE_VERSION = "1.0.0";
+    private static final String ZOOKEEPER_ADDRESS = 
"zookeeper://127.0.0.1:2181";

Review Comment:
   Hard-coding the ZooKeeper address makes the sample brittle in CI / 
containerized environments (where ZooKeeper is often not on localhost). 
Consider reading this from a system property/env var (with the current value as 
default) so users can run the sample without editing code.



##########
generic/go-client/cmd/client.go:
##########
@@ -24,54 +24,64 @@ 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/filter/generic"
+       "dubbo.apache.org/dubbo-go/v3/config"
+       "dubbo.apache.org/dubbo-go/v3/config/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 (
-       TripleServerURL = "tri://127.0.0.1:50052"
-       UserProvider    = "org.apache.dubbo.samples.UserProvider"
-       ServiceVersion  = "1.0.0"
+       AppName          = "generic-go-client"
+       RegistryID       = "zk"
+       ZookeeperAddress = "127.0.0.1:2181"
+       UserProvider     = "org.apache.dubbo.samples.UserProvider"
+       ServiceVersion   = "1.0.0"
 )
 
 func main() {
        hessian.RegisterPOJO(&pkg.User{})
 
-       ins, err := dubbo.NewInstance(
-               dubbo.WithName("generic-go-client"),
-       )
-       if err != nil {
+       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 {
                panic(err)
        }
 
-       cli, err := ins.NewClient(
-               client.WithClientProtocolTriple(),
-               client.WithClientSerialization(constant.Hessian2Serialization),
-       )
-       if err != nil {
-               panic(err)
+       refConf := config.ReferenceConfig{
+               InterfaceName: UserProvider,
+               RegistryIDs:   []string{RegistryID},
+               Protocol:      tpconst.TRIPLE,
+               Cluster:       "failover",
+               Group:         "triple",
+               Version:       ServiceVersion,
+               Serialization: constant.Hessian2Serialization,
+               Generic:       "true",
        }
-
-       genericService, err := cli.NewGenericService(
-               UserProvider,
-               client.WithURL(TripleServerURL),
-               client.WithVersion(ServiceVersion),
-               client.WithGroup("triple"),
-       )
-       if err != nil {
+       if err := refConf.Init(rootConfig); err != nil {
                panic(err)
        }
+       refConf.GenericLoad(AppName)
+
+       genericService := refConf.GetRPCService().(*generic.GenericService)

Review Comment:
   `refConf.GenericLoad(AppName)` is called without checking whether it 
succeeded (it commonly returns an error in dubbo-go APIs), and the subsequent 
type assertion `.(*generic.GenericService)` can panic if the RPC service wasn’t 
initialized/loaded as expected. Handle the error return from `GenericLoad` (or 
verify its signature and act accordingly) and guard the type assertion with an 
`ok` check (or use a more explicit accessor) so failures become actionable 
errors instead of panics.
   



##########
generic/README.md:
##########
@@ -2,21 +2,21 @@
 
 [English](README.md) | [中文](README_zh.md)
 
-This sample demonstrates how to use generic invocation with both Dubbo and 
Triple protocols for Go-Java interoperability. Generic invocation allows 
calling remote services without generating stubs or having the service 
interface locally.
+This sample demonstrates generic invocation over the Triple protocol for 
Go-Java interoperability. Generic invocation allows calling remote services 
without generating stubs or having the service interface locally.

Review Comment:
   The docs now state the sample is “over the Triple protocol”, but the Java 
server code still configures both a Dubbo protocol service and a Triple service 
(e.g., `DUBBO_PORT` + `TRIPLE_PORT`). Either update the docs to mention the 
server exposes both while the clients test Triple, or remove/disable the Dubbo 
protocol export in the sample to match the updated narrative.



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