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
This commit is contained in:
Joshua Harlow
2014-05-05 15:30:28 -07:00
parent 258e009ae3
commit 4422644de3

View File

@@ -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 "