You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/04/12 16:11:11 UTC

[GitHub] [dubbo-go-samples] AlexStocks commented on a change in pull request #88: enhance router examples

AlexStocks commented on a change in pull request #88:
URL: https://github.com/apache/dubbo-go-samples/pull/88#discussion_r611766694



##########
File path: router/README.md
##########
@@ -1,35 +1,44 @@
-## 1.Run java server & java client following 
-
-[README](https://github.com/dubbogo/dubbogo-samples/blob/master/README.md)(You must run java program to initialize configuration in zookeeper)
-
-## 2.Use router feature 
-
-### 2.1 use condition router with config file 
+# Router Examples
+
+## Background
+
+This example will show how tag router and condition router can be used in a Dubbo go application. For more information about tag router and condition router, pls. refer to the docs:  [Conditional routing rules](https://dubbo.apache.org/en/docs/v2.7/user/examples/routing-rule/#conditional-routing-rules) and [Tag routing rules](https://dubbo.apache.org/en/docs/v2.7/user/examples/routing-rule/#tag-routing-rules).
+
+## Config router with local config file 
+
+Router can be configured with a local config yaml file. You can find the sample config file under "go-client/config/router_config.yml", for example:
+
+```yaml
+routerRules:
+  - scope: application
+    force: true
+    runtime: false
+    enabled: true
+    valid: true
+    priority: 1
+    key: demo-provider
+    tags:
+      - name: beijing
+        addresses: [192.168.1.1, $HOST_IP]
+      - name: shenzhen
+        addresses: [192.168.1.3, 192.168.1.4]
+```
 
-Modify [router_config.yml](go-client/profiles/dev/router_config.yml) what you want to config
+You may notice '$HOST_IP' in the config file. Before run the example, you will need to replace it with the provider's IP. In order to find the provider's IP, you may consider to execute the following command:
 
-[How to write router_config.yml](http://dubbo.apache.org/en-us/docs/user/demos/routing-rule.html)
+```bash
+ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'
+```
 
-### 2.2 use tag router
-[How to use tag router](http://dubbo.apache.org/en-us/docs/user/demos/routing-rule.html)
+## Config router with config center
 
-### 2.3 with config center
+It is convenient to use environment variable 'CONF_ROUTER_FILE_PATH' to config router config in development environment. Compared to local router config file, it is more preferable to use [Dubbo Admin](https://github.com/apache/dubbo-admin) to configure router config for production use.
 
-#### zookeeper
 
-Use [dubbo-admin](https://github.com/apache/dubbo-admin) to set condition router file.
+In order to have router configs notified, the Dubbo consumer must have a config center pre-configure like below:

Review comment:
       like below: = as follows,




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org