diff options
author | Vitja Makarov <vitja.makarov@gmail.com> | 2013-08-25 10:18:11 +0400 |
---|---|---|
committer | Vitja Makarov <vitja.makarov@gmail.com> | 2013-09-04 23:34:56 +0400 |
commit | ef342bea2df7dc5bd9821af6ce9a67873fdb47b4 (patch) | |
tree | 8f59349bf904df4d01181f4b9ee93edb0b9ef05e /redis/sentinel.py | |
parent | 0967fa0063cff9c016f1c833e890cf061d3f2fab (diff) | |
download | redis-py-ef342bea2df7dc5bd9821af6ce9a67873fdb47b4.tar.gz |
Allow to specify user's own connection pool class
Diffstat (limited to 'redis/sentinel.py')
-rw-r--r-- | redis/sentinel.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/redis/sentinel.py b/redis/sentinel.py index e9e4473..77624c4 100644 --- a/redis/sentinel.py +++ b/redis/sentinel.py @@ -155,7 +155,8 @@ class Sentinel(object): return slaves return [] - def master_for(self, service_name, redis_class=StrictRedis, **kwargs): + def master_for(self, service_name, redis_class=StrictRedis, + connection_pool_class=SentinelConnectionPool, **kwargs): """ Returns redis client instance for master of ``service_name``. @@ -166,14 +167,16 @@ class Sentinel(object): the pool are closed. By default redis.StrictRedis class is used you can override this with - ``redis_class`` argument. All other arguments are passed directly to - the SentinelConnectionPool. + ``redis_class`` argument. Use ``connection_pool_class`` to specify + your own connection pool class instead of SentinelConnectionPool. All + other arguments are passed directly to the SentinelConnectionPool. """ kwargs['is_master'] = True - connection_pool = SentinelConnectionPool(service_name, self, **kwargs) - return redis_class(connection_pool=connection_pool) + return redis_class(connection_pool=connection_pool_class( + service_name, self, **kwargs)) - def slave_for(self, service_name, redis_class=StrictRedis, **kwargs): + def slave_for(self, service_name, redis_class=StrictRedis, + connection_pool_class=SentinelConnectionPool, **kwargs): """ Returns redis client instance for slave of ``service_name``. @@ -181,9 +184,10 @@ class Sentinel(object): address each time before establishing new connection. By default redis.StrictRedis class is used you can override this with - ``redis_class`` argument. All other arguments are passed directly to - the SentinelConnectionPool. + ``redis_class`` argument. Use ``connection_pool_class`` to specify + your own connection pool class instead of SentinelConnectionPool. All + other arguments are passed directly to the SentinelConnectionPool. """ kwargs['is_master'] = False - connection_pool = SentinelConnectionPool(service_name, self, **kwargs) - return redis_class(connection_pool=connection_pool) + return redis_class(connection_pool=connection_pool_class( + service_name, self, **kwargs)) |