Don't shutdown old nodes in mdns registry

This commit is contained in:
Asim Aslam 2019-09-26 16:46:09 +01:00
parent 06975f64b7
commit ef7bb46884

View File

@ -11,7 +11,6 @@ import (
"time" "time"
"github.com/micro/mdns" "github.com/micro/mdns"
hash "github.com/mitchellh/hashstructure"
) )
var ( var (
@ -27,7 +26,6 @@ type mdnsTxt struct {
} }
type mdnsEntry struct { type mdnsEntry struct {
hash uint64
id string id string
node *mdns.Server node *mdns.Server
} }
@ -109,13 +107,6 @@ func (m *mdnsRegistry) Register(service *Service, opts ...RegisterOption) error
var gerr error var gerr error
for _, node := range service.Nodes { for _, node := range service.Nodes {
// create hash of service; uint64
h, err := hash.Hash(node, nil)
if err != nil {
gerr = err
continue
}
var seen bool var seen bool
var e *mdnsEntry var e *mdnsEntry
@ -128,14 +119,11 @@ func (m *mdnsRegistry) Register(service *Service, opts ...RegisterOption) error
} }
// already registered, continue // already registered, continue
if seen && e.hash == h { if seen {
continue continue
// hash doesn't match, shutdown
} else if seen {
e.node.Shutdown()
// doesn't exist // doesn't exist
} else { } else {
e = &mdnsEntry{hash: h} e = &mdnsEntry{}
} }
txt, err := encode(&mdnsTxt{ txt, err := encode(&mdnsTxt{