Add comments to set_ttl method

To explain how it's supposed to work and why it manupulates with the
cache of `Cluster` object (calls `reset_cluster`)
This commit is contained in:
Alexander Kukushkin
2016-05-30 17:02:29 +02:00
parent b7359e7b0d
commit 9379c036d5
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -101,7 +101,9 @@ class Consul(AbstractDCS):
except Exception:
logger.exception("Can not destroy session %s", self._session)
self._session = None
# force `watch` method to call `AbstractDCS.watch` instead of watching for leader key
self.reset_cluster()
# fire up an event to wake up from `watch` and immediately run HA loop (to create the new session)
self.event.set()
self._ttl = ttl
+2
View File
@@ -218,7 +218,9 @@ class Etcd(AbstractDCS):
def set_ttl(self, ttl):
ttl = int(ttl)
if self._ttl != ttl:
# force `watch` method to call `AbstractDCS.watch` instead of watching for leader key
self.reset_cluster()
# fire up an event to wake up from `watch` and immediately run HA loop (to update TTL of leader and member)
self.event.set()
self._ttl = ttl