This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new 9a9c24a01 fix(router): use ApplicationKey instead of Tagkey to build
config key in Route method (#3251)
9a9c24a01 is described below
commit 9a9c24a010e3a1501409148e2152dc5046773bc0
Author: Aether <[email protected]>
AuthorDate: Mon Mar 16 21:02:23 2026 +0800
fix(router): use ApplicationKey instead of Tagkey to build config key in
Route method (#3251)
* fix(tag-router): use ApplicationKey instead of Tagkey to build config key
in Route method
* add unit tests
---------
Co-authored-by: Aetherance <[email protected]>
---
cluster/router/tag/router.go | 4 ++--
cluster/router/tag/router_test.go | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/cluster/router/tag/router.go b/cluster/router/tag/router.go
index 511e28d6c..8fde2d38a 100644
--- a/cluster/router/tag/router.go
+++ b/cluster/router/tag/router.go
@@ -52,8 +52,8 @@ func (p *PriorityRouter) Route(invokers []base.Invoker, url
*common.URL, invocat
logger.Warnf("[tag router] invokers from previous router is
empty")
return invokers
}
- // get prefix from invoker
- application := invokers[0].GetURL().GetParam(constant.Tagkey, "")
+ // get application name from invoker to look up tag routing config
+ application := invokers[0].GetURL().GetParam(constant.ApplicationKey,
"")
key := strings.Join([]string{application,
constant.TagRouterRuleSuffix}, "")
value, ok := p.routerConfigs.Load(key)
if !ok {
diff --git a/cluster/router/tag/router_test.go
b/cluster/router/tag/router_test.go
index 92538ea7e..7b51aec91 100644
--- a/cluster/router/tag/router_test.go
+++ b/cluster/router/tag/router_test.go
@@ -334,6 +334,26 @@ func TestRouter(t *testing.T) {
result := p.Route(invokerList, url3,
invocation.NewRPCInvocation("GetUser", nil, nil))
assert.Len(t, result, 3)
})
+
+ t.Run("dynamicTag_withApplicationKey", func(t *testing.T) { //NOSONAR
+ p, _ := NewTagPriorityRouter()
+ ivk1 := base.NewBaseInvoker(url1)
+ ivk1.GetURL().SetParam(constant.ApplicationKey, "test-app")
//NOSONAR
+ ivk2 := base.NewBaseInvoker(url2)
+ ivk2.GetURL().SetParam(constant.ApplicationKey, "test-app")
//NOSONAR
+
+ configKey := "test-app" + constant.TagRouterRuleSuffix //NOSONAR
+ p.routerConfigs.Store(configKey, global.RouterConfig{
+ Enabled: truePointer,
+ Valid: truePointer,
+ Tags: []global.Tag{{
+ Addresses: []string{"192.168.0.1:20000"},
//NOSONAR
+ }},
+ })
+
+ result := p.Route([]base.Invoker{ivk1, ivk2}, consumerUrl,
invocation.NewRPCInvocation("GetUser", nil, nil))
+ assert.Len(t, result, 1)
+ })
}
func TestNotify(t *testing.T) {