Make TTL > heartbeat by at least one second to prevent key from disappearing before next heartbeat

Signed-off-by: Mike Goelzer <mike@goelzer.com>
This commit is contained in:
Mike Goelzer 2015-04-02 19:34:30 -07:00
parent 64d691a448
commit bcca57bda8
1 changed files with 2 additions and 1 deletions

View File

@ -40,7 +40,8 @@ func (s *EtcdDiscoveryService) Initialize(uris string, heartbeat int) error {
}
s.client = etcd.NewClient(entries)
s.ttl = uint64(heartbeat * 3 / 2)
// ttl should always be > heartbeat, even if heartbeat = 1 or 0
s.ttl = uint64(heartbeat*3/2) + 1
s.path = "/" + parts[1] + "/"
if _, err := s.client.CreateDir(s.path, s.ttl); err != nil {
if etcdError, ok := err.(*etcd.EtcdError); ok {