Skip to content
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

fix: Consumers try to reconnect to the metadata service of offline providers infinitely #2166

Merged
merged 13 commits into from
Dec 25, 2022
2 changes: 2 additions & 0 deletions metadata/service/local/service_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ func (m *MetadataServiceProxy) GetMetadataInfo(revision string) (*common.Metadat
invocation.WithAttachments(map[string]interface{}{constant.AsyncKey: "false"}),
invocation.WithParameterValues([]reflect.Value{rV}))
res := m.invkr.Invoke(context.Background(), inv)
// when request finished, invoker will colse
defer m.invkr.Destroy()
if res.Error() != nil {
logger.Errorf("could not get the metadata info from remote provider: %v", res.Error())
return nil, res.Error()
Expand Down
7 changes: 1 addition & 6 deletions metadata/service/local_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,7 @@ func NewBaseMetadataServiceProxyFactory(creator MetadataServiceProxyCreator) *Ba
}

func (b *BaseMetadataServiceProxyFactory) GetProxy(ins registry.ServiceInstance) MetadataService {
key := ins.GetServiceName() + "##" + getExportedServicesRevision(ins)
if proxy, ok := b.proxies.Load(key); ok {
return proxy.(MetadataService)
}
v, _ := b.proxies.LoadOrStore(key, b.creator(ins))
return v.(MetadataService)
return b.creator(ins).(MetadataService)
}

func getExportedServicesRevision(serviceInstance registry.ServiceInstance) string {
Expand Down