From 859ecb18725b3f3955d9d98ba4a89edce3d5b157 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Sun, 29 Sep 2019 21:42:30 +0100 Subject: [PATCH] Dont set default TTL. Stop tracking nodes with no TTL --- registry/memory/memory.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/registry/memory/memory.go b/registry/memory/memory.go index f7134bf2..72d62298 100644 --- a/registry/memory/memory.go +++ b/registry/memory/memory.go @@ -73,8 +73,8 @@ func (m *Registry) ttlPrune() { case <-prune.C: m.Lock() for nodeTrackId, node := range m.nodes { - // if we exceed the TTL threshold we need to stop tracking the node - if time.Since(node.lastSeen) > node.ttl { + // if the TTL has been set and we exceed the hresholdset by it we stop tracking the node + if node.ttl.Seconds() != 0.0 && time.Since(node.lastSeen) > node.ttl { // split nodeTrackID into service Name, Version and Node Id trackIdSplit := strings.Split(nodeTrackId, "+") svcName, svcVersion, nodeId := trackIdSplit[0], trackIdSplit[1], trackIdSplit[2] @@ -183,11 +183,6 @@ func (m *Registry) Register(s *registry.Service, opts ...registry.RegisterOption o(&options) } - // if no TTL has been set, set it to DefaultTTL - if options.TTL.Seconds() == 0.0 { - options.TTL = DefaultTTL - } - if service, ok := m.Services[s.Name]; !ok { m.Services[s.Name] = []*registry.Service{s} // add all nodes into nodes map to track their TTL