-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V2.0.2 namingClient.Subscribe 订阅服务状态, 当服务变化推送过来,因为集群为"",无法取到缓存回调方法 #474
Comments
接受服务信息日志打印:service key:%s was updated to:%s service key: TEST-CHENG-LEIGOTES |
没有复现,可以用最新版本再试下 |
v2.2.5 ,如果"clusters" : "DEFAULT“ 在调用Subscribe 复现 bug,但是 "clusters" : "”没有复现 |
有解决方式吗? nacos-sdk-go/example/service/main.go Line 149 in 61ecaa8
|
// Subscribe key = serviceName+groupName+cluster
// Note: We call add multiple SubscribeCallback with the same key.
err := namingClient.Subscribe(vo.SubscribeParam{
ServiceName: "demo.go",
GroupName: "group-a", // default value is DEFAULT_GROUP
Clusters: []string{"DEFAULT"}, // default value is DEFAULT
SubscribeCallback: func(services []model.SubscribeService, err error) {
log.Printf("\n\n callback return services:%s \n\n", utils.ToJsonString(services))
},
})
问题:源码中
funcs, ok := ed.callbackFuncMap.Get(cacheKey)
获取不到回调方法 因为 cacheKey组成的cluster字段为"",订阅初始化是存入的cacheKey中cluster为"DEFAULT"
func (ed *SubscribeCallback) ServiceChanged(cacheKey string, service *model.Service) {
funcs, ok := ed.callbackFuncMap.Get(cacheKey)
if ok {
for _, funcItem := range funcs.([]*func(services []model.Instance, err error)) {
if len(service.Hosts) == 0 {
(*funcItem)(service.Hosts, errors.New("[client.Subscribe] subscribe failed,hosts is empty"))
continue
}
(*funcItem)(service.Hosts, nil)
}
}
}
另外cluster为""的好像是
common/remote/rpc/server_request_handler.go
中RequestReply方法,请求返回的数据中 clusters为""
The text was updated successfully, but these errors were encountered: