Skip to content

Conversation

@97ZQ
Copy link

@97ZQ 97ZQ commented Oct 28, 2025

#3045 primarily for exposing the API of Router, a global router_config was added. Then, the initialization and cloning of instances were supplemented in options.go, and methods for mutual conversion between global and config were also added in compat.go

@Alanxtl
Copy link
Contributor

Alanxtl commented Oct 28, 2025

we use https://github.com/dubbogo/tools?tab=readme-ov-file#imports-formatter to format import blocks, for u, you should download the tool and cd to the root of dubbo-go and use imports-formatter

@97ZQ
Copy link
Author

97ZQ commented Oct 28, 2025

we use https://github.com/dubbogo/tools?tab=readme-ov-file#imports-formatter to format import blocks, for u, you should download the tool and cd to the root of dubbo-go and use imports-formatter

yes,sir

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 4.76190% with 100 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.22%. Comparing base (1a7b169) to head (5c74cb1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
compat.go 6.89% 52 Missing and 2 partials ⚠️
global/router_config.go 0.00% 39 Missing ⚠️
options.go 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3065      +/-   ##
==========================================
+ Coverage   39.64%   40.22%   +0.57%     
==========================================
  Files         457      458       +1     
  Lines       39075    32635    -6440     
==========================================
- Hits        15493    13127    -2366     
+ Misses      22318    18241    -4077     
- Partials     1264     1267       +3     

☔ View full report in Codecov by Sentry.
📢 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.

@AlexStocks AlexStocks requested a review from Copilot October 29, 2025 02:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds router configuration support to the Dubbo-Go framework by introducing RouterConfig in the global package and integrating it into InstanceOptions. The feature was previously commented out and is now being enabled.

  • Uncommented and activated the Router field in InstanceOptions
  • Created new global/router_config.go with RouterConfig and Tag structs
  • Added compatibility layer functions to convert between global and config package types

Reviewed Changes

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

File Description
options.go Uncommented Router field, added default initialization and CloneRouter method
global/router_config.go New file defining RouterConfig and Tag structs with Clone method
compat.go Added compatibility functions for bidirectional conversion between global and config RouterConfig types

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

copy(newConditions, c.Conditions)

newTags := make([]Tag, len(c.Tags))
copy(newTags, c.Tags)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Shallow copy of Tags slice creates shared references to ParamMatch pointers. The Tag struct contains a Match field of type []*common.ParamMatch, which means the pointers will be shared between the original and cloned objects. This should perform a deep copy by iterating through each Tag and cloning its Match slice. Example fix:

newTags := make([]Tag, len(c.Tags))
for i, tag := range c.Tags {
newMatch := make([]*common.ParamMatch, len(tag.Match))
for j, match := range tag.Match {
if match != nil {
matchCopy := *match
newMatch[j] = &matchCopy
}
}
newAddresses := make([]string, len(tag.Addresses))
copy(newAddresses, tag.Addresses)
newTags[i] = Tag{
Name:      tag.Name,
Match:     newMatch,
Addresses: newAddresses,
}
}
Suggested change
copy(newTags, c.Tags)
for i, tag := range c.Tags {
// Deep copy Match slice
newMatch := make([]*common.ParamMatch, len(tag.Match))
for j, match := range tag.Match {
if match != nil {
matchCopy := *match
newMatch[j] = &matchCopy
}
}
// Deep copy Addresses slice
newAddresses := make([]string, len(tag.Addresses))
copy(newAddresses, tag.Addresses)
newTags[i] = Tag{
Name: tag.Name,
Match: newMatch,
Addresses: newAddresses,
}
}

Copilot uses AI. Check for mistakes.
ScriptType: c.ScriptType,
Script: c.Script,
}

Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Extra blank line before closing brace. Remove the blank line at line 463 to maintain consistency with the codebase style (see compatShutdownConfig at line 443 and other similar functions).

Suggested change

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@Alanxtl Alanxtl left a comment

Choose a reason for hiding this comment

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

excellent work,
目前来看现在只是暴露了global.RouteConfig,但是没有暴露给用户的接口,比如在dubbo-go/options.go里面应该暴露WithRoute(),在dubbo-go/cluster/router里面应该新建options.go暴露其他的WithXXX(),XXX都有什么可以参考config/router_config.go里面的setXXX()

@1kasa
Copy link
Contributor

1kasa commented Oct 29, 2025

excellent work,  出色的工作, 目前来看现在只是暴露了global.RouteConfig,但是没有暴露给用户的接口,比如在dubbo-go/options.go里面应该暴露WithRoute(),在dubbo-go/cluster/router里面应该新建options.go暴露其他的WithXXX(),XXX都有什么可以参考config/router_config.go里面的setXXX()

I agree with this statement, and after you've added the imported API, I hope you'll add examples to dubbo-go-samples for verification.Additionally, submit to the develop branch

97ZQ and others added 2 commits October 29, 2025 15:27
@97ZQ
Copy link
Author

97ZQ commented Oct 29, 2025

excellent work,  出色的工作, 目前来看现在只是暴露了global.RouteConfig,但是没有暴露给用户的接口,比如在dubbo-go/options.go里面应该暴露WithRoute(),在dubbo-go/cluster/router里面应该新建options.go暴露其他的WithXXX(),XXX都有什么可以参考config/router_config.go里面的setXXX()

I agree with this statement, and after you've added the imported API, I hope you'll add examples to dubbo-go-samples for verification.Additionally, submit to the develop branch

thanks,i will try my best to implement it recently.

@sonarqubecloud
Copy link

@97ZQ 97ZQ closed this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants