yangpixi opened a new pull request, #3208:
URL: https://github.com/apache/dubbo-go/pull/3208
### Description
Fixes # 3203
1. client在从nacos获取Provider并生成invoker时,缺少对Tag的初始化,导致Provider设置的dubbo.tag无效。
2. #3185
引入的代码存在类型转换问题,当用户传入的attachment是map[string]string类型的时候,attachment无法正确附加进生成的invocation
#### 测试代码:
server端:
```
ins, err := dubbo.NewInstance(
dubbo.WithName(ServerName),
dubbo.WithRegistry(
registry.WithNacos(),
registry.WithAddress(RegistryAddress),
),
dubbo.WithProtocol(
protocol.WithID("dubbo"),
protocol.WithDubbo(),
protocol.WithPort(DubboServerPort),
),
dubbo.WithTag("testTag"),
)
```
client端:
```
ins, err := dubbo.NewInstance(
dubbo.WithName("generic-dubbo-client"),
dubbo.WithRegistry(
registry.WithNacos(),
registry.WithAddress(RegistryAddress),
),
dubbo.WithConfigCenter(
config_center.WithNacos(),
config_center.WithAddress(RegistryAddress),
),
)
cli, err := ins.NewClient(
client.WithClientProtocolDubbo(),
client.WithClientSerialization(constant.Hessian2Serialization),
)
conn, err := createServiceConnection(cli, UserProvider)
ctxWithTag := context.WithValue(context.Background(),
constant.AttachmentKey, map[string]any{constant.Tagkey: "test",
constant.ForceUseTag: "false"})
call := func(methodName string, params []interface{}) (interface{},
error) {
var result interface{}
err := conn.CallUnary(
ctxWithTag,
params,
&result,
methodName,
)
```
测试情况:
1. client带上a标签,server带上a标签,调用成功
2. client带上a标签,server带上b标签,调用失败
3. client不带标签,server不带标签,调用成功
4. client不带标签,server带上a标签,调用失败
5. client带上a标签,server不带标签,force设置为false,调用成功
6. client带上a标签,server不带标签,force设置为true,调用失败
### Checklist
- [x] I confirm the target branch is `develop`
- [x] Code has passed local testing
- [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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]