mirror of
https://github.com/go-micro/go-micro.git
synced 2024-11-24 08:02:32 +02:00
Dont set default TTL. Stop tracking nodes with no TTL
This commit is contained in:
parent
204c7d1fcf
commit
859ecb1872
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user