You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "MaoMengww (via GitHub)" <gi...@apache.org> on 2026/08/19 05:29:02 UTC

[PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

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

   ### Description
   - Add doc comments to the ScriptRouter lifecycle methods (Process, Route, Notify, ...) describing the script instance lifecycle, reuse (reference-counting) behavior, and failure handling
   - Add doc comments to ScriptInstances, jsInstances, program, and the instance pool
   - Add unit tests covering: instance creation failure, script execution failure, instance reuse, and concurrent instance fetching
   
   #### Worth mentioning:
   
   - This PR also fixes a potential nil-pointer panic: in router.go lines 120 and 124, *cfg.Enabled was dereferenced unconditionally. Since RouterConfig is populated by YAML decoding and Enabled has no default value, omitting the field in the rule would crash the router. The dereference is now guarded, dafault true, and a regression test has been added.
   - The goja runtime pooling in this file is only half-implemented: insPool *sync.Pool (intended to store *goja.Runtime) only has Get calls but no Put, so every compilation creates a new runtime, degrading performance. if the maintainers agree — I'll open a separate issue for it and fix it.
   
   Refs https://github.com/apache/dubbo-go/issues/3644 (task11)
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] I have run `make fmt` to format my code
   - [x] I have run `make test` to run local tests
   - [x] I have added tests that prove my fix is effective or that my feature works
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#issuecomment-5337926564

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3682) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3682&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3682&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3682&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3682)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#discussion_r3810421636


##########
cluster/router/script/router.go:
##########
@@ -117,11 +123,11 @@ func (s *ScriptRouter) Process(event *config_center.ConfigChangeEvent) {
 			logger.Error("[Router][Script] applicationName field must be set in config")
 			return
 		}
-		if !*cfg.Enabled {
+		if cfg.Enabled != nil && !*cfg.Enabled {

Review Comment:
   cfg.Enabled == nil是不是也应该走这个分支呀
   也就是 cfg.Enabled == nil || !*cfg.Enabled



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#issuecomment-5338076203

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3682) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3682&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3682&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3682&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3682&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3682)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "MaoMengww (via GitHub)" <gi...@apache.org>.
MaoMengww commented on code in PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#discussion_r3810500335


##########
cluster/router/script/router.go:
##########
@@ -117,11 +123,11 @@ func (s *ScriptRouter) Process(event *config_center.ConfigChangeEvent) {
 			logger.Error("[Router][Script] applicationName field must be set in config")
 			return
 		}
-		if !*cfg.Enabled {
+		if cfg.Enabled != nil && !*cfg.Enabled {
 			logger.Infof("[Router][Script] enabled field equals false, this rule will be ignored, script=%s", cfg.Script)
 		}
 		// rewrite to ScriptRouter
-		s.enabled = *cfg.Enabled
+		s.enabled = cfg.Enabled == nil || *cfg.Enabled

Review Comment:
   同上



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#issuecomment-5337973452

   ## [Codecov](https://app.codecov.io/gh/apache/dubbo-go/pull/3682?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 55.28%. Comparing base ([`60d1c2a`](https://app.codecov.io/gh/apache/dubbo-go/commit/60d1c2a949f0ee0da4be3fe09fb79d295491e040?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`cb1acb2`](https://app.codecov.io/gh/apache/dubbo-go/commit/cb1acb28f416b52acc93ade7f5d0791588b5a698?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 937 commits behind head on develop.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           develop    #3682      +/-   ##
   ===========================================
   + Coverage    46.76%   55.28%   +8.51%     
   ===========================================
     Files          295      475     +180     
     Lines        17172    36816   +19644     
   ===========================================
   + Hits          8031    20354   +12323     
   - Misses        8287    14843    +6556     
   - Partials       854     1619     +765     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/dubbo-go/pull/3682?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#discussion_r3810421636


##########
cluster/router/script/router.go:
##########
@@ -117,11 +123,11 @@ func (s *ScriptRouter) Process(event *config_center.ConfigChangeEvent) {
 			logger.Error("[Router][Script] applicationName field must be set in config")
 			return
 		}
-		if !*cfg.Enabled {
+		if cfg.Enabled != nil && !*cfg.Enabled {

Review Comment:
   cfg.Enabled == nil是不是也应该走这个分支呀



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on code in PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#discussion_r3810421636


##########
cluster/router/script/router.go:
##########
@@ -117,11 +123,11 @@ func (s *ScriptRouter) Process(event *config_center.ConfigChangeEvent) {
 			logger.Error("[Router][Script] applicationName field must be set in config")
 			return
 		}
-		if !*cfg.Enabled {
+		if cfg.Enabled != nil && !*cfg.Enabled {

Review Comment:
   这个分支加个else 处理一下



##########
cluster/router/script/router.go:
##########
@@ -117,11 +123,11 @@ func (s *ScriptRouter) Process(event *config_center.ConfigChangeEvent) {
 			logger.Error("[Router][Script] applicationName field must be set in config")
 			return
 		}
-		if !*cfg.Enabled {
+		if cfg.Enabled != nil && !*cfg.Enabled {
 			logger.Infof("[Router][Script] enabled field equals false, this rule will be ignored, script=%s", cfg.Script)
 		}
 		// rewrite to ScriptRouter
-		s.enabled = *cfg.Enabled
+		s.enabled = cfg.Enabled == nil || *cfg.Enabled

Review Comment:
   这里不应该是cfg.Enabled != nil && *cfg.Enabled吗



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "MaoMengww (via GitHub)" <gi...@apache.org>.
MaoMengww commented on code in PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#discussion_r3810484133


##########
cluster/router/script/router.go:
##########
@@ -117,11 +123,11 @@ func (s *ScriptRouter) Process(event *config_center.ConfigChangeEvent) {
 			logger.Error("[Router][Script] applicationName field must be set in config")
 			return
 		}
-		if !*cfg.Enabled {
+		if cfg.Enabled != nil && !*cfg.Enabled {

Review Comment:
   我认为的是当Enabled没有填写时默认为true, 如果不这样的话我会进行修改



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "MaoMengww (via GitHub)" <gi...@apache.org>.
MaoMengww commented on code in PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682#discussion_r3810484133


##########
cluster/router/script/router.go:
##########
@@ -117,11 +123,11 @@ func (s *ScriptRouter) Process(event *config_center.ConfigChangeEvent) {
 			logger.Error("[Router][Script] applicationName field must be set in config")
 			return
 		}
-		if !*cfg.Enabled {
+		if cfg.Enabled != nil && !*cfg.Enabled {

Review Comment:
   我认为的是当Enabled没有填写时默认为true, 如果认为这样不合理的话我马上进行修改



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] docs(router): complete script router comments and unit test coverage [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl merged PR #3682:
URL: https://github.com/apache/dubbo-go/pull/3682


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org