Additional check enforcing ttl >= 10s for Consul and ephemeral entries

Signed-off-by: Alexandre Beslic <abronan@docker.com>
This commit is contained in:
Alexandre Beslic 2015-05-25 12:36:27 -07:00
parent b5c8062933
commit bf6427ad23
1 changed files with 9 additions and 2 deletions

View File

@ -16,6 +16,10 @@ const (
// watched key has changed. This affects the minimum time it takes to // watched key has changed. This affects the minimum time it takes to
// cancel a watch. // cancel a watch.
DefaultWatchWaitTime = 15 * time.Second DefaultWatchWaitTime = 15 * time.Second
// MinimumTimeToLive is the minimum TTL value allowed by Consul for
// Ephemeral entries
MinimumTimeToLive = 10 * time.Second
) )
// Consul embeds the client and watches // Consul embeds the client and watches
@ -81,8 +85,11 @@ func (s *Consul) setTimeout(time time.Duration) {
} }
// SetEphemeralTTL sets the ttl for ephemeral nodes // SetEphemeralTTL sets the ttl for ephemeral nodes
func (s *Consul) setEphemeralTTL(time time.Duration) { func (s *Consul) setEphemeralTTL(ttl time.Duration) {
s.ephemeralTTL = time if ttl < MinimumTimeToLive {
log.Fatal("Consul does not allow a ttl < 10s, please specify a ttl >= 10s")
}
s.ephemeralTTL = ttl
} }
// CreateEphemeralSession creates the a global session // CreateEphemeralSession creates the a global session