Skip to content
Snippets Groups Projects
Commit b968f7b9 authored by flycash's avatar flycash
Browse files

Add unregiste implementation

parent 198ddc33
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ import (
"github.com/apache/dubbo-go/common/observer"
"github.com/apache/dubbo-go/metadata/mapping"
"github.com/apache/dubbo-go/metadata/service"
"github.com/apache/dubbo-go/metadata/service/inmemory"
"github.com/apache/dubbo-go/metadata/service/remote"
"github.com/apache/dubbo-go/registry"
"github.com/apache/dubbo-go/registry/servicediscovery/proxy"
"github.com/apache/dubbo-go/registry/servicediscovery/synthesizer"
......@@ -76,8 +76,10 @@ func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
serviceNameMapping := extension.GetServiceNameMapping(url.GetParam(constant.SERVICE_NAME_MAPPING_KEY, ""))
// TODO it's need to get implement by factory
metaDataService := inmemory.NewMetadataService()
metaDataService, err := remote.NewMetadataService()
if err != nil {
return nil, perrors.WithMessage(err, "could not init metadata service")
}
return &serviceDiscoveryRegistry{
url: url,
serviceDiscovery: serviceDiscovery,
......@@ -91,11 +93,17 @@ func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
}
func (s *serviceDiscoveryRegistry) UnRegister(url common.URL) error {
panic("implement me")
if !shouldRegister(url) {
return nil
}
return s.metaDataService.UnexportURL(url)
}
func (s *serviceDiscoveryRegistry) UnSubscribe(*common.URL, registry.NotifyListener) error {
panic("implement me")
func (s *serviceDiscoveryRegistry) UnSubscribe(url *common.URL, listener registry.NotifyListener) error {
if !shouldSubscribe(*url) {
return nil
}
return s.metaDataService.UnsubscribeURL(*url)
}
func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
......@@ -125,6 +133,7 @@ func (s *serviceDiscoveryRegistry) GetUrl() common.URL {
}
func (s *serviceDiscoveryRegistry) IsAvailable() bool {
// TODO(whether available depends on metadata service and service discovery)
return true
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment