Redis Sentinel master_for, slave_for returns a Redis client (#6269)

This commit is contained in:
Stéphane Brunner
2021-11-12 12:23:12 +01:00
committed by GitHub
parent bfdb87b9fd
commit 9c9853967d

View File

@@ -1,8 +1,11 @@
from typing import Any
from typing import Any, Type, TypeVar, overload
from redis.client import Redis
from redis.connection import Connection, ConnectionPool
from redis.exceptions import ConnectionError
_Redis = TypeVar("_Redis", bound=Redis[Any])
class MasterNotFoundError(ConnectionError): ...
class SlaveNotFoundError(ConnectionError): ...
@@ -39,5 +42,11 @@ class Sentinel(object):
def discover_master(self, service_name): ...
def filter_slaves(self, slaves): ...
def discover_slaves(self, service_name): ...
def master_for(self, service_name, redis_class=..., connection_pool_class=..., **kwargs) -> None: ...
def slave_for(self, service_name, redis_class=..., connection_pool_class=..., **kwargs) -> None: ...
@overload
def master_for(self, service_name: str, *, connection_pool_class=..., **kwargs) -> Redis[Any]: ...
@overload
def master_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ...
@overload
def slave_for(self, service_name: str, connection_pool_class=..., **kwargs) -> Redis[Any]: ...
@overload
def slave_for(self, service_name: str, redis_class: Type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ...