Skip to content

feat(router): support static script router config#3419

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

feat(router): support static script router config#3419
leno23 wants to merge 4 commits into
apache:developfrom
leno23:codex/script-router-static-config-3203

Conversation

@leno23

@leno23 leno23 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What

  • Add SetStaticConfig support to ScriptRouter for application-scoped static router configs.
  • Compile static JavaScript rules the same way dynamic config-center updates are compiled.
  • Add regression coverage for enabled, disabled, and non-script static configs.

Why

Issue #3203 tracks router follow-ups and explicitly calls out that RouterConfig already has ScriptType and Script fields, but ScriptRouter did not implement the static config interface.

Validation

  • go test ./cluster/router/script
  • go test ./cluster/router/...
  • git diff --check

Refs #3203

@codecov-commenter

codecov-commenter commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.50%. Comparing base (60d1c2a) to head (3a34450).
⚠️ Report is 845 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3419      +/-   ##
===========================================
+ Coverage    46.76%   53.50%   +6.73%     
===========================================
  Files          295      493     +198     
  Lines        17172    38406   +21234     
===========================================
+ Hits          8031    20550   +12519     
- Misses        8287    16212    +7925     
- Partials       854     1644     +790     

☔ 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 static (application-scoped) router config injection support for ScriptRouter, enabling bootstrap configuration via RouterConfig without YAML parsing and aligning static compilation behavior with config-center updates. This addresses the gap noted in #3203 where RouterConfig already includes ScriptType/Script but ScriptRouter didn’t implement the static config interface.

Changes:

  • Implement SetStaticConfig(*global.RouterConfig) on ScriptRouter to accept static script rules and compile them on set.
  • Ensure static updates replace any previously compiled script state (destroy old, compile new; disabled/invalid disables routing).
  • Add regression tests covering enabled/disabled/unsupported/invalid static script configs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cluster/router/script/router.go Adds SetStaticConfig to apply/compile static script router rules and manage prior compiled state.
cluster/router/script/router_test.go Adds unit tests for static script config application, replacement, disablement, and invalid/unsupported cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cluster/router/script/router.go
Comment on lines +91 to +95
s.enabled = cfg.Enabled == nil || *cfg.Enabled
if !s.enabled {
logger.Infof("[Router][Script] static config is disabled, script=%s", cfg.Script)
return
}
@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
@leno23 leno23 force-pushed the codex/script-router-static-config-3203 branch from 2e904b2 to 3a34450 Compare June 16, 2026 05:10
@sonarqubecloud

Copy link
Copy Markdown

@leno23

leno23 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

The failed Integration Test appears to be runner infrastructure rather than a code failure. The failing step ended with link: mapping output file failed: no space left on device while building the router/tag sample. I tried to rerun the failed job, but I do not have repository admin rights to rerun Actions. Please rerun the failed Integration Test when convenient.

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

4 participants