|
4 | 4 |
|
5 | 5 | from redis.client import Redis |
6 | 6 | from redis.commands import SentinelCommands |
7 | | -from redis.connection import Connection, ConnectionPool, SSLConnection |
| 7 | +from redis.connection import ( |
| 8 | + BlockingConnectionPool, |
| 9 | + Connection, |
| 10 | + ConnectionPool, |
| 11 | + SSLConnection, |
| 12 | +) |
8 | 13 | from redis.exceptions import ConnectionError, ReadOnlyError, ResponseError, TimeoutError |
9 | 14 | from redis.utils import str_if_bytes |
10 | 15 |
|
@@ -134,14 +139,7 @@ def rotate_slaves(self): |
134 | 139 | raise SlaveNotFoundError(f"No slave found for {self.service_name!r}") |
135 | 140 |
|
136 | 141 |
|
137 | | -class SentinelConnectionPool(ConnectionPool): |
138 | | - """ |
139 | | - Sentinel backed connection pool. |
140 | | -
|
141 | | - If ``check_connection`` flag is set to True, SentinelManagedConnection |
142 | | - sends a PING command right after establishing the connection. |
143 | | - """ |
144 | | - |
| 142 | +class _SentinelConnectionPoolMixin: |
145 | 143 | def __init__(self, service_name, sentinel_manager, **kwargs): |
146 | 144 | kwargs["connection_class"] = kwargs.get( |
147 | 145 | "connection_class", |
@@ -195,6 +193,27 @@ def rotate_slaves(self): |
195 | 193 | return self.proxy.rotate_slaves() |
196 | 194 |
|
197 | 195 |
|
| 196 | +class SentinelConnectionPool(_SentinelConnectionPoolMixin, ConnectionPool): |
| 197 | + """ |
| 198 | + Sentinel backed connection pool. |
| 199 | +
|
| 200 | + If ``check_connection`` flag is set to True, SentinelManagedConnection |
| 201 | + sends a PING command right after establishing the connection. |
| 202 | + """ |
| 203 | + |
| 204 | + |
| 205 | +class SentinelBlockingConnectionPool( |
| 206 | + _SentinelConnectionPoolMixin, |
| 207 | + BlockingConnectionPool, |
| 208 | +): |
| 209 | + """ |
| 210 | + Sentinel blocking connection pool. |
| 211 | +
|
| 212 | + If ``check_connection`` flag is set to True, SentinelManagedConnection |
| 213 | + sends a PING command right after establishing the connection. |
| 214 | + """ |
| 215 | + |
| 216 | + |
198 | 217 | class Sentinel(SentinelCommands): |
199 | 218 | """ |
200 | 219 | Redis Sentinel cluster client |
|
0 commit comments