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


##########
README.md:
##########
@@ -44,6 +44,9 @@ Please refer to [HOWTO.md](HOWTO.md) for detailed 
instructions on running the sa
   * `otlp_http_exporter`: Uses `otlpHttpExporter` to export tracing data, 
covering `dubbo`/`triple`/`jsonrpc` protocols.
 * `registry`: Examples of using different service registries (e.g., Nacos, 
Zookeeper).
 * `retry`: Demonstrates retry mechanisms in Dubbo-go RPC calls.
+* `router`: Various Dubbo-go router examples.
+  * `router/tag`: Dubbo-go tag router examples.
+  * `router/condition`: Dubbo-to condition router examples.

Review Comment:
   The router list has a typo: "Dubbo-to" should be "Dubbo-go".
   ```suggestion
     * `router/condition`: Dubbo-go condition router examples.
   ```



##########
router/tag/README_CN.md:
##########
@@ -0,0 +1,33 @@
+# Tag router
+这个例子展示了如何使用dubbo-go的tag router功能。
+
+## 前置准备
+
+- Docker以及Docker Compose环境来运行Nacos注册中心。
+- Go 1.23+版本。
+
+## 如何运行
+
+### 启动Nacos注册中心
+参考这个教程来[启动Nacos](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/)。
+
+### 运行服务端(Provider)
+在这个示例中,你将运行一个具有tag的server以及一个不具有tag的server。
+
+```shell
+$ go run ./go-server/cmd/server.go      # 无标签server
+$ go run ./go-tag-server/cmdserver_tag.go   # 有标签server

Review Comment:
   The command path for the tagged server looks incorrect 
(`./go-tag-server/cmdserver_tag.go`). It should point to the actual file under 
`go-tag-server/cmd/` so users can run the example as documented.
   ```suggestion
   $ go run ./go-server/cmd/server.go          # 无标签server
   $ go run ./go-tag-server/cmd/server_tag.go  # 有标签server
   ```



##########
router/tag/go-client/cmd/client.go:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "strings"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/common/constant"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/router/tag/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+)
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("tag-client"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new instance failed: %v", err)
+               panic(err)
+       }
+
+       cli, err := ins.NewClient()
+
+       if err != nil {
+               logger.Errorf("new client failed: %v", err)
+               panic(err)
+       }
+
+       svc, err := greet.NewGreetService(cli)
+
+       if err != nil {
+               logger.Errorf("new service failed: %v", err)
+               panic(err)
+       }
+
+       callGreet := func(name, tag, force, exp string) {
+               // set tag attachments for invocation
+               atta := map[string]string{
+                       constant.Tagkey:      tag,
+                       constant.ForceUseTag: force,
+               }
+               ctx := context.WithValue(context.Background(), 
constant.AttachmentKey, atta)
+
+               resp, err := svc.Greet(ctx, &greet.GreetRequest{Name: name})
+               // temporarily cancel checking for result, for PR # 3208 
(https://github.com/apache/dubbo-go/pull/3208)
+               // hasn't been merged to main branch yet, thus tag router still 
not works properly.
+
+               //checkRes(exp, resp.GetGreeting(), err)
+               printRes(resp, err)

Review Comment:
   `checkRes` is commented out with a note about an upstream PR, so the example 
no longer verifies the routing behavior and the `exp` argument is effectively 
dead. Consider either restoring the assertion (once the dependency is 
available) or removing the `exp` parameter / `checkRes` helper to keep the 
sample deterministic and easier to maintain.



##########
router/script/README_CN.md:
##########
@@ -0,0 +1,66 @@
+# Script router
+
+这个例子展示了如何使用dubbo-go的script router功能。
+
+[Enllish](README.md) | 中文

Review Comment:
   Spelling: the language link text should be "English".
   ```suggestion
   [English](README.md) | 中文
   ```



##########
router/README.md:
##########
@@ -0,0 +1,7 @@
+# Dubbo-go Router Sample
+
+English | [中文](README_CN.md)
+
+## Description
+
+This directory includes four types of dubbo-go router function.

Review Comment:
   This README says there are "four types" of router examples, but the 
directory currently contains tag/condition/script (3). Please update the count 
or rephrase (e.g., "multiple types") to match the actual contents.
   ```suggestion
   This directory includes multiple types of dubbo-go router function.
   ```



##########
README_CN.md:
##########
@@ -44,6 +44,9 @@
   * `otlp_http_exporter`:使用 `otlpHttpExporter` 导出追踪数据,覆盖 `dubbo` / `triple` / 
`jsonrpc` 协议。
 * `registry`:使用不同服务注册中心(如 Nacos、Zookeeper)的示例。
 * `retry`:Dubbo-go RPC 调用重试机制示例。
+* `router`: Dubbo-go 各种 Router 调用示例。
+  * `router/tag`: Dubbo-go 的 tag router 使用示例。
+  * `router/condition`: Dubbo-go 的 condition router 使用示例。

Review Comment:
   The Chinese sample index under `router` lists tag/condition, but this PR 
also adds a `router/script` example directory. Consider adding a 
`router/script` entry here to keep the index complete.
   ```suggestion
     * `router/condition`: Dubbo-go 的 condition router 使用示例。
     * `router/script`: Dubbo-go 的 script router 使用示例。
   ```



##########
router/script/go-server/cmd/server.go:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "strconv"
+       "strings"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/protocol"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+       TriPort         = 20001
+)
+
+type GreetServer struct {
+       srvPort int
+}
+
+func (srv *GreetServer) Greet(_ context.Context, req *greet.GreetRequest) (rep 
*greet.GreetResponse, err error) {
+       rep = &greet.GreetResponse{Greeting: req.Name + " from: " + 
strconv.Itoa(srv.srvPort)}
+       return rep, nil
+}
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("script-server"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(TriPort),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new instance failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := ins.NewServer()
+
+       if err != nil {
+               logger.Errorf("new server failed: %v", err)
+               panic(err)
+       }
+
+       if err := greet.RegisterGreetServiceHandler(srv, &GreetServer{srvPort: 
TriPort}); err != nil {
+               logger.Errorf("register service failed: %v", err)
+               panic(err)
+       }
+
+       if err := srv.Serve(); err != nil {
+               logger.Errorf("server serve failed: %v", err)
+               if strings.Contains(err.Error(), "client not connected") {
+                       logger.Errorf("hint: Nacos client not connected (gRPC). 
Check %s is reachable and gRPC port %d is open (Nacos 2.x default).", 
RegistryAddress, TriPort)

Review Comment:
   This hint message uses `TriPort` (the service port) as the "Nacos gRPC 
port". Nacos 2.x gRPC is typically on 9848 (when the HTTP port is 8848), so 
this hint is misleading. Consider using a dedicated `nacosGrpcPort` value 
instead of `TriPort`.



##########
router/script/README.md:
##########
@@ -0,0 +1,69 @@
+# Script Router
+
+This example demonstrates how to use the script router feature in dubbo-go.
+
+English | [中文](README_CN.md)
+
+## Prerequisites
+
+- Docker and Docker Compose environment to run the Nacos registry.
+- Go version 1.23+.
+- Nacos version 2.x+.
+
+## How to Run
+
+### Start Nacos Registry
+
+Follow this instruction to [install and start Nacos 
server](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/).
+
+### Run Server (Provider)
+
+In this example, you will run two servers providing services on ports 20000 
and 20001 respectively.
+
+```Shell
+$ go run ./go-server/cmd/server.go              # port 20000
+$ go run ./go-node2-server/cmd/server_node2.go  # port 20001
+```
+
+### Run Client (Consumer)
+
+In this example, the client will continuously call the Greet method in an 
infinite loop. You need to:
+
+- Start the client and observe the load balancing behavior during calls.
+
+- Set up the script router configuration in the Nacos registry, then observe 
the client's calls again.
+
+```Shell
+$ go run ./go-client/cmd/client.go
+```
+
+### Nacos Configuration
+
+Create a new configuration with the `Data ID` **script-server.script-router** 
and set the format to `yaml`.
+
+Set the Group to `DEFAULT_GROUP`.
+
+> Note: The naming convention in Nacos is {application.name}.{router_type}.
+
+```yaml
+scope: "application"
+key: "condition-server"

Review Comment:
   In the Nacos YAML snippet, `key: "condition-server"` doesn't match this 
example (`script-server.script-router` / application name `script-server`). The 
`key` should be `script-server` so users can apply the config to the correct 
app.
   ```suggestion
   key: "script-server"
   ```



##########
router/condition/go-node2-server/cmd/server_node2.go:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "strconv"
+       "strings"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/protocol"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+       TriPort         = 20000
+)
+
+type GreetServer struct {
+       srvPort int
+}
+
+func (srv *GreetServer) Greet(_ context.Context, req *greet.GreetRequest) (rep 
*greet.GreetResponse, err error) {
+       rep = &greet.GreetResponse{Greeting: req.Name + " from: " + 
strconv.Itoa(srv.srvPort)}
+       return rep, nil
+}
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("condition-server"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(TriPort),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new instance failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := ins.NewServer()
+
+       if err != nil {
+               logger.Errorf("new server failed: %v", err)
+               panic(err)
+       }
+
+       if err := greet.RegisterGreetServiceHandler(srv, &GreetServer{srvPort: 
TriPort}); err != nil {
+               logger.Errorf("register service failed: %v", err)
+               panic(err)
+       }
+
+       if err := srv.Serve(); err != nil {
+               logger.Errorf("server serve failed: %v", err)
+               if strings.Contains(err.Error(), "client not connected") {
+                       logger.Errorf("hint: Nacos client not connected (gRPC). 
Check %s is reachable and gRPC port %d is open (Nacos 2.x default).", 
RegistryAddress, TriPort)

Review Comment:
   This hint message uses `TriPort` (the service port) as the "Nacos gRPC 
port". Nacos 2.x gRPC is typically on 9848 (when the HTTP port is 8848), so 
this hint is misleading. Consider using a dedicated `nacosGrpcPort` value 
instead of `TriPort`.



##########
router/script/go-client/cmd/client.go:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "os/signal"
+       "syscall"
+       "time"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+)
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("script-client"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithConfigCenter( // configure config center to enable 
condition router

Review Comment:
   The comment says this config-center setup is to enable the "condition 
router", but this example is for the script router. Please adjust the comment 
to avoid misleading readers.
   ```suggestion
                dubbo.WithConfigCenter( // configure config center for script 
router
   ```



##########
README.md:
##########
@@ -44,6 +44,9 @@ Please refer to [HOWTO.md](HOWTO.md) for detailed 
instructions on running the sa
   * `otlp_http_exporter`: Uses `otlpHttpExporter` to export tracing data, 
covering `dubbo`/`triple`/`jsonrpc` protocols.
 * `registry`: Examples of using different service registries (e.g., Nacos, 
Zookeeper).
 * `retry`: Demonstrates retry mechanisms in Dubbo-go RPC calls.
+* `router`: Various Dubbo-go router examples.
+  * `router/tag`: Dubbo-go tag router examples.
+  * `router/condition`: Dubbo-to condition router examples.

Review Comment:
   The top-level sample index lists `router/tag` and `router/condition`, but 
this PR also adds `router/script`. Consider adding `router/script` here as well 
so the README accurately reflects the available router examples.
   ```suggestion
     * `router/condition`: Dubbo-to condition router examples.
     * `router/script`: Dubbo-go script router examples.
   ```



##########
router/condition/README.md:
##########
@@ -0,0 +1,68 @@
+# Condition router
+
+This example shows how to use dubbo-go's condition router.
+
+English | [中文](README_CN.md)
+
+## Prerequisites
+
+- Docker and docker compose to run Nacos registry.
+- Go Version 1.23+.
+- Nacos Version 2.x+.
+
+## How to run
+
+### Run Nacos registry
+
+Follow this instruction
+to [install and run 
Nacos](https://dubbo-next.staged.apache.org/zh-cn/overview/reference/integrations/nacos/).
+
+### Run server (Provider)
+
+In this example, you will run two servers on ports 20000 and 20001 
respectively.
+
+```shell
+$ go run ./go-server/cmd/server.go              # port 20000
+$ go run ./go-node2-server/cmd/server_node2.go  # port 20001
+```
+
+### Run client (Consumer)
+
+In this example, the client will keep calling Greet method in an infinity 
loop. You need to:
+
+- Start the client and observe the load balancing behavior during calls.
+
+- Set up the condition router configuration in the Nacos registry, then 
observe the client's calls again.
+
+```shell
+$ go run ./go-client/cmd/client.go
+```
+
+### Configuration of Nacos
+
+Create a new configuration with the `Data ID` 
**condition-server.condition-router** and set the format to `yaml`.
+
+Set the Group to `DEFAULT_GROUP`.
+
+> Note: The naming convention in Nacos is {application.name}.{router_type}.
+
+```yaml
+configVersion: V3.3.2
+scope: "application"
+key: "condition-server"
+priority: 1
+force: true
+enabled: true
+conditions:
+  - from:
+      match: "application = condition-client"
+    to:
+      - match: "port = 20001"
+```
+
+## Expected result
+
+- When the client starts without the condition router configuration in Nacos,
+  it will alternate calls between the two server endpoints.
+- When the client starts with the script router configured in Nacos,

Review Comment:
   The expected-result text says "script router" here, but this README is for 
the condition router example. Please update it to "condition router" so the 
instructions/results are consistent.
   ```suggestion
   - When the client starts with the condition router configured in Nacos,
   ```



##########
router/script/go-client/cmd/client.go:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "os/signal"
+       "syscall"
+       "time"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+)
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("script-client"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithConfigCenter( // configure config center to enable 
condition router
+                       config_center.WithNacos(),
+                       config_center.WithAddress(RegistryAddress),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new instance failed: %v", err)
+               panic(err)
+       }
+
+       cli, err := ins.NewClient()
+
+       if err != nil {
+               logger.Errorf("new client failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := greet.NewGreetService(cli)
+
+       if err != nil {
+               logger.Errorf("new service failed: %v", err)
+               panic(err)
+       }
+
+       ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, 
syscall.SIGTERM)
+       defer stop()
+
+       ticker := time.NewTicker(5 * time.Second)
+       defer ticker.Stop()
+
+       for {
+               select {
+               case <-ctx.Done():
+                       logger.Info("gracefully existing...")

Review Comment:
   Spelling/wording: "gracefully existing..." should be "gracefully exiting...".
   ```suggestion
                        logger.Info("gracefully exiting...")
   ```



##########
router/tag/go-tag-server/cmd/server_tag.go:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "strings"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/protocol"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/router/tag/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+)
+
+type GreetServer struct {
+       srvName string
+}
+
+func (srv *GreetServer) Greet(_ context.Context, req *greet.GreetRequest) 
(*greet.GreetResponse, error) {
+       rep := &greet.GreetResponse{Greeting: "receive: " + req.Name + ", 
response from: " + srv.srvName}
+       return rep, nil
+}
+
+func main() {
+
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("tag-server"),
+               dubbo.WithTag("test-tag"), // set application's tag
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(20001),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new dubbo instance failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := ins.NewServer()
+
+       if err != nil {
+               logger.Errorf("new dubbo server failed: %v", err)
+               panic(err)
+       }
+
+       if err := greet.RegisterGreetServiceHandler(srv, &GreetServer{srvName: 
"server-with-tag"}); err != nil {
+               logger.Errorf("register greet handler failed: %v", err)
+               panic(err)
+       }
+
+       if err := srv.Serve(); err != nil {
+               logger.Errorf("server serve failed: %v", err)
+               if strings.Contains(err.Error(), "client not connected") {
+                       logger.Errorf("hint: Nacos client not connected (gRPC). 
Check %s is reachable and gRPC port %d is open (Nacos 2.x default).", 
RegistryAddress, 20001)

Review Comment:
   This hint message uses the service's Triple port (20001) as the "Nacos gRPC 
port". Nacos 2.x gRPC is typically on 9848 (when the HTTP port is 8848), so 
this hint is misleading. Consider using a dedicated `nacosGrpcPort` (as in 
`registry/nacos/go-server/cmd/server.go`) instead of the service port.



##########
router/condition/go-client/cmd/client.go:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "os/signal"
+       "syscall"
+       "time"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       "dubbo.apache.org/dubbo-go/v3/config_center"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+)
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("condition-client"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithConfigCenter( // configure config center to enable 
condition router
+                       config_center.WithNacos(),
+                       config_center.WithAddress(RegistryAddress),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new instance failed: %v", err)
+               panic(err)
+       }
+
+       cli, err := ins.NewClient()
+
+       if err != nil {
+               logger.Errorf("new client failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := greet.NewGreetService(cli)
+
+       if err != nil {
+               logger.Errorf("new service failed: %v", err)
+               panic(err)
+       }
+
+       ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, 
syscall.SIGTERM)
+       defer stop()
+
+       ticker := time.NewTicker(5 * time.Second)
+       defer ticker.Stop()
+
+       for {
+               select {
+               case <-ctx.Done():
+                       logger.Info("gracefully existing...")

Review Comment:
   Spelling/wording: "gracefully existing..." should be "gracefully exiting...".
   ```suggestion
                        logger.Info("gracefully exiting...")
   ```



##########
router/README_CN.md:
##########
@@ -0,0 +1,7 @@
+# Dubbo-go Router 示例
+
+[English](README.md) | 中文
+
+## 描述
+
+这个文件夹包含了四种dubbo-go router功能的示例。

Review Comment:
   This README says there are "四种" router examples, but the directory currently 
contains tag/condition/script (3). Please update the count or rephrase to match 
the actual contents.
   ```suggestion
   这个文件夹包含了 dubbo-go router 功能的多个示例。
   ```



##########
router/script/go-node2-server/cmd/server_node2.go:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "strconv"
+       "strings"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/protocol"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+       TriPort         = 20000
+)
+
+type GreetServer struct {
+       srvPort int
+}
+
+func (srv *GreetServer) Greet(_ context.Context, req *greet.GreetRequest) (rep 
*greet.GreetResponse, err error) {
+       rep = &greet.GreetResponse{Greeting: req.Name + " from: " + 
strconv.Itoa(srv.srvPort)}
+       return rep, nil
+}
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("script-server"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(TriPort),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new instance failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := ins.NewServer()
+
+       if err != nil {
+               logger.Errorf("new server failed: %v", err)
+               panic(err)
+       }
+
+       if err := greet.RegisterGreetServiceHandler(srv, &GreetServer{srvPort: 
TriPort}); err != nil {
+               logger.Errorf("register service failed: %v", err)
+               panic(err)
+       }
+
+       if err := srv.Serve(); err != nil {
+               logger.Errorf("server serve failed: %v", err)
+               if strings.Contains(err.Error(), "client not connected") {
+                       logger.Errorf("hint: Nacos client not connected (gRPC). 
Check %s is reachable and gRPC port %d is open (Nacos 2.x default).", 
RegistryAddress, TriPort)

Review Comment:
   This hint message uses `TriPort` (the service port) as the "Nacos gRPC 
port". Nacos 2.x gRPC is typically on 9848 (when the HTTP port is 8848), so 
this hint is misleading. Consider using a dedicated `nacosGrpcPort` value 
instead of `TriPort`.



##########
router/condition/go-server/cmd/server.go:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "strconv"
+       "strings"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/protocol"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/direct/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+       TriPort         = 20001
+)
+
+type GreetServer struct {
+       srvPort int
+}
+
+func (srv *GreetServer) Greet(_ context.Context, req *greet.GreetRequest) (rep 
*greet.GreetResponse, err error) {
+       rep = &greet.GreetResponse{Greeting: req.Name + " from: " + 
strconv.Itoa(srv.srvPort)}
+       return rep, nil
+}
+
+func main() {
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("condition-server"),
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(TriPort),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new instance failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := ins.NewServer()
+
+       if err != nil {
+               logger.Errorf("new server failed: %v", err)
+               panic(err)
+       }
+
+       if err := greet.RegisterGreetServiceHandler(srv, &GreetServer{srvPort: 
TriPort}); err != nil {
+               logger.Errorf("register service failed: %v", err)
+               panic(err)
+       }
+
+       if err := srv.Serve(); err != nil {
+               logger.Errorf("server serve failed: %v", err)
+               if strings.Contains(err.Error(), "client not connected") {
+                       logger.Errorf("hint: Nacos client not connected (gRPC). 
Check %s is reachable and gRPC port %d is open (Nacos 2.x default).", 
RegistryAddress, TriPort)

Review Comment:
   This hint message uses `TriPort` (the service port) as the "Nacos gRPC 
port". Nacos 2.x gRPC is typically on 9848 (when the HTTP port is 8848), so 
this hint is misleading. Consider using a dedicated `nacosGrpcPort` value 
instead of `TriPort`.



##########
router/tag/go-server/cmd/server.go:
##########
@@ -0,0 +1,91 @@
+/*
+ * 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 main
+
+import (
+       "context"
+       "strings"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3"
+       _ "dubbo.apache.org/dubbo-go/v3/imports"
+       "dubbo.apache.org/dubbo-go/v3/protocol"
+       "dubbo.apache.org/dubbo-go/v3/registry"
+
+       "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+       greet "github.com/apache/dubbo-go-samples/router/tag/proto"
+)
+
+const (
+       RegistryAddress = "127.0.0.1:8848"
+)
+
+type GreetServer struct {
+       srvName string
+}
+
+func (srv *GreetServer) Greet(_ context.Context, req *greet.GreetRequest) 
(*greet.GreetResponse, error) {
+       rep := &greet.GreetResponse{Greeting: "receive: " + req.Name + ", 
response from: " + srv.srvName}
+       return rep, nil
+}
+
+func main() {
+
+       ins, err := dubbo.NewInstance(
+               dubbo.WithName("tag-server"),
+               dubbo.WithTag(""), // set application's tag
+               dubbo.WithRegistry(
+                       registry.WithNacos(),
+                       registry.WithAddress(RegistryAddress),
+               ),
+               dubbo.WithProtocol(
+                       protocol.WithTriple(),
+                       protocol.WithPort(20000),
+               ),
+       )
+
+       if err != nil {
+               logger.Errorf("new dubbo instance failed: %v", err)
+               panic(err)
+       }
+
+       srv, err := ins.NewServer()
+
+       if err != nil {
+               logger.Errorf("new dubbo server failed: %v", err)
+               panic(err)
+       }
+
+       if err := greet.RegisterGreetServiceHandler(srv, &GreetServer{srvName: 
"server-without-tag"}); err != nil {
+               logger.Errorf("register greet handler failed: %v", err)
+               panic(err)
+       }
+
+       if err := srv.Serve(); err != nil {
+               logger.Errorf("server serve failed: %v", err)
+               if strings.Contains(err.Error(), "client not connected") {
+                       logger.Errorf("hint: Nacos client not connected (gRPC). 
Check %s is reachable and gRPC port %d is open (Nacos 2.x default).", 
RegistryAddress, 20000)

Review Comment:
   This hint message uses the service's Triple port (20000) as the "Nacos gRPC 
port". Nacos 2.x gRPC is typically on 9848 (when the HTTP port is 8848), so 
this hint is misleading. Consider using a dedicated `nacosGrpcPort` (as in 
`registry/nacos/go-server/cmd/server.go`) instead of the service port.



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