English | 中文
Quickly experience Polaris' service routing capabilities in dubbogo
Polaris Server Standalone Version Installation Documentation
Polaris Server Cluster Version Installation Documentation
Polaris Service Routing Usage Document
When using PolarisMesh‘s service route capability, you need to enable PolarisMesh’s registration discovery function in dubbogo firstly.
dubbo: registries: polarisMesh: protocol: polaris address: ${Polaris server IP}:8091 namespace: ${Polaris namespace information} token: ${Polaris resource authentication token} # If the Polaris server has enabled authentication for the client, you need to configure this parameter provider: services: UserProvider: interface: org.apache.dubbo.UserProvider.Test
The implementation of the PolarisMesh PriorityRouter extension point in dubbogo can automatically identify the request label information that needs to participate in service routing from the current RPC call context and request information according to the service route rules configured by the user.
Enter the cmd directory of server-prod, server-pre, and server-dev respectively, and execute the following commands
export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yaml" go run .
When you see the following log, it means that the server side started successfully
INFO dubbo/dubbo_protocol.go:84 [DUBBO Protocol] Export service:
Enter the cmd directory of go-client and execute the following command
export DUBBO_GO_CONFIG_PATH="../conf/dubbogo.yml" export uid=user-1 go run .
When you see the following log, it means that go-client successfully discovered go-server and made an RPC call
INFO cmd/main.go:75 response: &{A001 Alex Stocks 18 2022-11-19 12:52:38.092 +0800 CST}
Execute the following commands respectively
export uid= go run . export uid=user-1 go run . export uid=user-2
When you see the following log, it means that the routing policy configured in PolarisMesh has taken effect
# export uid= 2022-11-26T13:39:31.637+0800 INFO cmd/main.go:78 response: &{A001 [Prod] Alex Stocks 18 2022-11-26 13:39:31.637 +0800 CST} 2022-11-26T13:39:31.842+0800 INFO cmd/main.go:78 response: &{A001 [Prod] Alex Stocks 18 2022-11-26 13:39:31.841 +0800 CST} 2022-11-26T13:39:32.043+0800 INFO cmd/main.go:78 response: &{A001 [Prod] Alex Stocks 18 2022-11-26 13:39:32.043 +0800 CST} 2022-11-26T13:39:32.247+0800 INFO cmd/main.go:78 response: &{A001 [Prod] Alex Stocks 18 2022-11-26 13:39:32.247 +0800 CST} 2022-11-26T13:39:32.452+0800 INFO cmd/main.go:78 response: &{A001 [Prod] Alex Stocks 18 2022-11-26 13:39:32.452 +0800 CST} # export uid=user-1 2022-11-26T13:39:51.053+0800 INFO cmd/main.go:78 response: &{A001 [Pre] Alex Stocks 18 2022-11-26 13:39:51.053 +0800 CST} 2022-11-26T13:39:51.257+0800 INFO cmd/main.go:78 response: &{A001 [Pre] Alex Stocks 18 2022-11-26 13:39:51.257 +0800 CST} 2022-11-26T13:39:51.459+0800 INFO cmd/main.go:78 response: &{A001 [Pre] Alex Stocks 18 2022-11-26 13:39:51.459 +0800 CST} 2022-11-26T13:39:51.662+0800 INFO cmd/main.go:78 response: &{A001 [Pre] Alex Stocks 18 2022-11-26 13:39:51.662 +0800 CST} 2022-11-26T13:39:51.866+0800 INFO cmd/main.go:78 response: &{A001 [Pre] Alex Stocks 18 2022-11-26 13:39:51.866 +0800 CST} # export uid=user-2 2022-11-26T13:42:39.351+0800 INFO cmd/main.go:78 response: &{A001 [Dev] Alex Stocks 18 2022-11-26 13:42:39.351 +0800 CST} 2022-11-26T13:42:39.555+0800 INFO cmd/main.go:78 response: &{A001 [Dev] Alex Stocks 18 2022-11-26 13:42:39.555 +0800 CST} 2022-11-26T13:42:39.760+0800 INFO cmd/main.go:78 response: &{A001 [Dev] Alex Stocks 18 2022-11-26 13:42:39.76 +0800 CST} 2022-11-26T13:42:39.962+0800 INFO cmd/main.go:78 response: &{A001 [Dev] Alex Stocks 18 2022-11-26 13:42:39.961 +0800 CST} 2022-11-26T13:42:40.165+0800 INFO cmd/main.go:78 response: &{A001 [Dev] Alex Stocks 18 2022-11-26 13:42:40.165 +0800 CST}