diff --git a/registry/consul/service_discovery.go b/registry/consul/service_discovery.go index a69f9ec698194b5b482c9f549b867752e84a81bf..5767a2c813d785464061d21bd4f857ccb55acaa5 100644 --- a/registry/consul/service_discovery.go +++ b/registry/consul/service_discovery.go @@ -48,9 +48,7 @@ const ( ) var ( - // 16 would be enough. We won't use concurrentMap because in most cases, there are not race condition - instanceMap = make(map[string]registry.ServiceDiscovery, 16) - initLock sync.Mutex + initLock sync.Mutex ) // init will put the service discovery into extension @@ -61,20 +59,6 @@ func init() { // newConsulServiceDiscovery will create new service discovery instance // use double-check pattern to reduce race condition func newConsulServiceDiscovery(name string) (registry.ServiceDiscovery, error) { - instance, ok := instanceMap[name] - if ok { - return instance, nil - } - - initLock.Lock() - defer initLock.Unlock() - - // double check - instance, ok = instanceMap[name] - if ok { - return instance, nil - } - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the instance because the config is invalid") @@ -94,9 +78,7 @@ func newConsulServiceDiscovery(name string) (registry.ServiceDiscovery, error) { }, nil } -// nacosServiceDiscovery is the implementation of service discovery based on nacos. -// There is a problem, the go client for nacos does not support the id field. -// we will use the metadata to store the id of ServiceInstance +// consulServiceDiscovery is the implementation of service discovery based on consul. type consulServiceDiscovery struct { group string // descriptor is a short string about the basic information of this instance