Skip to content

feat(router): support static affinity router config#3420

Open
leno23 wants to merge 5 commits into
apache:developfrom
leno23:codex/affinity-router-static-config-3203
Open

feat(router): support static affinity router config#3420
leno23 wants to merge 5 commits into
apache:developfrom
leno23:codex/affinity-router-static-config-3203

Conversation

@leno23

@leno23 leno23 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What

  • Add AffinityAware to static RouterConfig and preserve it through clone/compat conversion.
  • Implement SetStaticConfig for service and application affinity routers with scope filtering.
  • Add tests for static affinity routing, invalid configs, scope handling, and config cloning.

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 SetStaticConfig entry point.

Validation

  • go test ./cluster/router/affinity ./global ./config
  • go test ./cluster/router/...
  • go test .
  • git diff --check

Refs #3203

@codecov-commenter

codecov-commenter commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.13559% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.67%. Comparing base (60d1c2a) to head (f04bb52).
⚠️ Report is 847 commits behind head on develop.

Files with missing lines Patch % Lines
cluster/router/affinity/router.go 87.03% 5 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AffinityAware to global.RouterConfig and config.RouterConfig, including clone + compat conversion support.
  • Implement SetStaticConfig for 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.

Comment thread cluster/router/affinity/router.go
@Alanxtl

Alanxtl commented Jun 16, 2026

Copy link
Copy Markdown
Member

@yangpixi @Aetherance help review this, is this pr necessary?

@Alanxtl Alanxtl added ✏️ Feature 3.3.2 version 3.3.2 labels Jun 16, 2026
@Alanxtl Alanxtl linked an issue Jun 16, 2026 that may be closed by this pull request
Comment thread cluster/router/affinity/router.go
@Aetherance

Copy link
Copy Markdown
Contributor

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

Comment thread cluster/router/affinity/router.go Outdated
@leno23

leno23 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the affinity static wrapper feedback in f04bb52.

What changed:

  • ServiceAffinityRoute.SetStaticConfig and ApplicationAffinityRoute.SetStaticConfig now return early when the static config is same-scope but has an empty AffinityAware.Key, matching the condition/tag wrapper behavior.
  • Added regression coverage to ensure such empty affinity configs do not clear an already-applied static affinity rule.

Validation:

  • go test ./cluster/router/affinity passed.
  • gofmt and git diff --check passed.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[讨论] dubbo-go router report

6 participants