Aetherance opened a new pull request, #3252:
URL: https://github.com/apache/dubbo-go/pull/3252

   ### Description
   
   Currently, router configurations in **dubbo-go** can only be updated through 
dynamic configuration centers. This PR introduces support for statically 
configuring routers through code, eliminating the need for a config center.
   
   ---
   
   ### Key Changes
   
   1. **StaticConfigSetter Interface**
   
      * Added in `cluster/router/router.go`.
      * Allows routers to receive static configs and decide whether to apply 
them based on their own logic.
   
   2. **Client Options Integration**
   
      * New options: `WithRouter(…)`, `SetClientRouters(…)`
      * Config propagation: `ClientOptions.Routers → ReferenceOptions.Routers → 
URL attribute`
   
   3. **Router Chain Injection**
   
      * Added `injectStaticRouters()` and `injectRouterConfig()` in `chain.go`.
      * Supports condition matching, application name matching, force/enabled 
flags.
   
   4. **Router Implementations**
   
      * **Condition Router**: parses string conditions, applies service/app 
scopes, handles force/enabled flags
      * **Tag Router**: validates tags, sets proper enabled/valid flags
   
   ---
   
   ### Usage
   
   ```go
   ins, _ := dubbo.NewInstance(
       dubbo.WithName("demo-consumer"),
       dubbo.WithRouter(
           router.WithScope(constant.RouterScopeService),
           router.WithKey("com.example.HelloService"),  
           router.WithConditions([]string{
               "tag = gray => host = gray-provider",
           }),
       ),
   )
   ```
   
   ### Checklist
   
   * [x] Target branch is `develop`
   * [x] Local tests passed
   * [x] Tests added to verify the feature or fix
   


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