1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Update the watcher

This commit is contained in:
Asim 2016-01-26 21:10:27 +00:00
parent d1d9daa572
commit ce0c5908a6

View File

@ -53,15 +53,26 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
for _, e := range entries { for _, e := range entries {
serviceName = e.Service.Service serviceName = e.Service.Service
id := e.Node.Node // version is now a tag
key := e.Service.Service + e.Service.ID version, found := decodeVersion(e.Service.Tags)
version := e.Service.ID // service ID is now the node id
id := e.Service.ID
// key is always the version
key := version
// address is service address
address := e.Service.Address
// We're adding service version but // if we can't get the new type of version
// don't want to break backwards compatibility // use old the old ways
if id == version { if !found {
key = e.Service.Service + "default" // id was set as node
version = "" id = e.Node.Node
// key was service id
key = e.Service.ID
// version was service id
version = e.Service.ID
// address was address
address = e.Node.Address
} }
svc, ok := serviceMap[key] svc, ok := serviceMap[key]
@ -76,7 +87,7 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
svc.Nodes = append(svc.Nodes, &Node{ svc.Nodes = append(svc.Nodes, &Node{
Id: id, Id: id,
Address: e.Node.Address, Address: address,
Port: e.Service.Port, Port: e.Service.Port,
Metadata: decodeMetadata(e.Service.Tags), Metadata: decodeMetadata(e.Service.Tags),
}) })