fix(router): fix wrong option configuration, add script-related options#3221
fix(router): fix wrong option configuration, add script-related options#3221AlexStocks merged 1 commit intoapache:developfrom
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3221 +/- ##
===========================================
+ Coverage 46.76% 47.90% +1.13%
===========================================
Files 295 463 +168
Lines 17172 33750 +16578
===========================================
+ Hits 8031 16168 +8137
- Misses 8287 16278 +7991
- Partials 854 1304 +450 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes critical bugs in the router options configuration and adds support for script-related options to enable the ScriptRouter functionality. According to the linked issue #3203, ScriptRouter existed but had its registration commented out, and these changes are part of making it functional.
Changes:
- Fixed
WithRuntimefunction to correctly setopts.Router.Runtimeinstead of incorrectly settingopts.Router.Force - Fixed
WithEnabledfunction to correctly setopts.Router.Enabledinstead of incorrectly settingopts.Router.Force - Added
WithScriptfunction to configure the script content for ScriptRouter - Added
WithScriptTypefunction to configure the script type (e.g., JavaScript, Groovy) for ScriptRouter
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -93,5 +93,16 @@ func WithTags(tags []global.Tag) Option { | |||
| return func(opts *Options) { | |||
| opts.Router.Tags = tags | |||
| } | |||
| } | |||
|
|
|||
| func WithScript(script string) Option { | |||
| return func(opts *Options) { | |||
| opts.Router.Script = script | |||
| } | |||
| } | |||
|
|
|||
| func WithScriptType(scriptType string) Option { | |||
| return func(opts *Options) { | |||
| opts.Router.ScriptType = scriptType | |||
| } | |||
| } | |||
There was a problem hiding this comment.
Test coverage is missing for the option functions in this file. Following the established pattern in the codebase (such as metrics/options_test.go and otel/trace/options_test.go), each WithXxx function should have a corresponding TestWithXxx test case. Please add tests for WithRuntime, WithEnabled, WithScript, and WithScriptType to verify they correctly set their respective fields in opts.Router.



Description
relation: #3203
Checklist
develop