use metadata helper

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-10-09 16:51:58 +03:00
parent 34d93306d6
commit 2fc47782cf

View File

@ -3,6 +3,7 @@ package registry
import ( import (
"net" "net"
"github.com/unistack-org/micro/v3/metadata"
"github.com/unistack-org/micro/v3/registry" "github.com/unistack-org/micro/v3/registry"
"github.com/unistack-org/micro/v3/server" "github.com/unistack-org/micro/v3/server"
"github.com/unistack-org/micro/v3/util/addr" "github.com/unistack-org/micro/v3/util/addr"
@ -172,12 +173,8 @@ func NewService(s server.Server) (*registry.Service, error) {
node := &registry.Node{ node := &registry.Node{
Id: opts.Name + "-" + opts.Id, Id: opts.Name + "-" + opts.Id,
Address: net.JoinHostPort(addr, port), Address: net.JoinHostPort(addr, port),
Metadata: opts.Metadata,
}
if node.Metadata == nil {
node.Metadata = make(map[string]string, 3)
} }
node.Metadata = metadata.Copy(opts.Metadata)
node.Metadata["server"] = s.String() node.Metadata["server"] = s.String()
node.Metadata["broker"] = opts.Broker.String() node.Metadata["broker"] = opts.Broker.String()