mirror of
https://github.com/go-micro/go-micro.git
synced 2025-04-23 11:07:43 +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:
|
case <-prune.C:
|
||||||
m.Lock()
|
m.Lock()
|
||||||
for nodeTrackId, node := range m.nodes {
|
for nodeTrackId, node := range m.nodes {
|
||||||
// if we exceed the TTL threshold we need to stop tracking the node
|
// if the TTL has been set and we exceed the hresholdset by it we stop tracking the node
|
||||||
if time.Since(node.lastSeen) > node.ttl {
|
if node.ttl.Seconds() != 0.0 && time.Since(node.lastSeen) > node.ttl {
|
||||||
// split nodeTrackID into service Name, Version and Node Id
|
// split nodeTrackID into service Name, Version and Node Id
|
||||||
trackIdSplit := strings.Split(nodeTrackId, "+")
|
trackIdSplit := strings.Split(nodeTrackId, "+")
|
||||||
svcName, svcVersion, nodeId := trackIdSplit[0], trackIdSplit[1], trackIdSplit[2]
|
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)
|
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 {
|
if service, ok := m.Services[s.Name]; !ok {
|
||||||
m.Services[s.Name] = []*registry.Service{s}
|
m.Services[s.Name] = []*registry.Service{s}
|
||||||
// add all nodes into nodes map to track their TTL
|
// add all nodes into nodes map to track their TTL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user