feat(router): support static affinity router config#3420
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3420 +/- ##
===========================================
+ Coverage 46.76% 53.67% +6.90%
===========================================
Files 295 493 +198
Lines 17172 38442 +21270
===========================================
+ Hits 8031 20633 +12602
- Misses 8287 16156 +7869
- Partials 854 1653 +799 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds support for injecting static affinity router configuration (in addition to existing dynamic config-center rules) by extending RouterConfig with AffinityAware and wiring it through clone/compat conversion and affinity router static setters.
Changes:
- Add
AffinityAwaretoglobal.RouterConfigandconfig.RouterConfig, including clone + compat conversion support. - Implement
SetStaticConfigfor service/application affinity routers with scope filtering and validation. - Add unit tests covering static affinity routing behavior, invalid configs, scope handling, and compat/clone preservation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| global/router_config.go | Adds AffinityAware to static router config and preserves it in Clone(). |
| global/config_test.go | Extends router clone test to assert AffinityAware is cloned. |
| config/router_config.go | Adds AffinityAware to config-layer RouterConfig. |
| compat.go | Preserves AffinityAware when converting global router config to config router config. |
| compat_test.go | Adds test verifying compat conversion includes AffinityAware. |
| cluster/router/affinity/router.go | Adds static config injection entry points and implements affinityRoute.SetStaticConfig. |
| cluster/router/affinity/router_test.go | Adds tests for static affinity routing, invalid configs, and scope filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@yangpixi @Aetherance help review this, is this pr necessary? |
@Alanxtl Previously static router config only covered the tag and condition routers. This PR adds it for the affinity router and fills a real gap. I think it's necessary. |
|
Addressed the affinity static wrapper feedback in f04bb52. What changed:
Validation:
|
|



What
AffinityAwareto staticRouterConfigand preserve it through clone/compat conversion.SetStaticConfigfor service and application affinity routers with scope filtering.Why
Issue #3203 lists affinity static route configuration as a router follow-up. The router already supports dynamic affinity rules, but static config injection had no affinity fields or
SetStaticConfigentry point.Validation
Refs #3203