From 9180fc0f44f04a035d59acfce587e2ecaf773e47 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 5 May 2014 15:30:28 -0700 Subject: [PATCH] Allow command and connection retry configuration When kazoo needs to retry commands or retry connections there is a specific set of configuration that can be provided to adjust these; allow that configuration to be passed to the client configuration method. Change-Id: I9c57e81ae3f82c7358ddabc7804a28fee7734c93 --- taskflow/utils/kazoo_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/taskflow/utils/kazoo_utils.py b/taskflow/utils/kazoo_utils.py index a2b5390c..8ca8bf52 100644 --- a/taskflow/utils/kazoo_utils.py +++ b/taskflow/utils/kazoo_utils.py @@ -75,10 +75,16 @@ def check_compatible(client, min_version=None, max_version=None): def make_client(conf): """Creates a kazoo client given a configuration dictionary.""" + # See: http://kazoo.readthedocs.org/en/latest/api/client.html client_kwargs = { 'read_only': bool(conf.get('read_only')), 'randomize_hosts': bool(conf.get('randomize_hosts')), } + # See: http://kazoo.readthedocs.org/en/latest/api/retry.html + if 'command_retry' in conf: + client_kwargs['command_retry'] = conf['command_retry'] + if 'connection_retry' in conf: + client_kwargs['connection_retry'] = conf['connection_retry'] hosts = _parse_hosts(conf.get("hosts", "localhost:2181")) if not hosts or not isinstance(hosts, six.string_types): raise TypeError("Invalid hosts format, expected "