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

Fix Etcd BUG

parent 80411a42
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ func SetServiceDiscovery(protocol string, creator func(name string) (registry.Se
func GetServiceDiscovery(protocol string, name string) (registry.ServiceDiscovery, error) {
creator, ok := discoveryCreatorMap[protocol]
if !ok {
return nil, perrors.New("Could not find the service discovery with name: " + name)
return nil, perrors.New("Could not find the service discovery with discovery protocol: " + protocol)
}
return creator(name)
}
......@@ -41,7 +41,7 @@ import (
const DEFAULT_ROOT = "dubbo"
func init() {
extension.SetMetadataReportFactory("etcd", func() factory.MetadataReportFactory {
extension.SetMetadataReportFactory(constant.ETCDV3_KEY, func() factory.MetadataReportFactory {
return &etcdMetadataReportFactory{}
})
}
......
......@@ -89,8 +89,13 @@ func (e *etcdV3ServiceDiscovery) Register(instance registry.ServiceInstance) err
if nil != e.client {
ins, err := jsonutil.EncodeJSON(instance)
if err == nil {
e.client.Create(path, string(ins))
e.services.Add(instance.GetServiceName())
err = e.client.Update(path, string(ins))
if err != nil {
logger.Errorf("cannot register the instance: %s", string(ins), err)
} else {
e.services.Add(instance.GetServiceName())
}
}
}
......
......@@ -144,7 +144,7 @@ func NewServiceDiscoveryClient(opts ...Option) *Client {
newClient, err := NewClient(options.name, options.endpoints, options.timeout, options.heartbeat)
if err != nil {
logger.Warnf("new etcd client (name{%s}, etcd addresses{%v}, timeout{%d}) = error{%v}",
logger.Errorf("new etcd client (name{%s}, etcd addresses{%v}, timeout{%d}) = error{%v}",
options.name, options.endpoints, options.timeout, err)
return nil
}
......
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