Skip to content

Commit acde146

Browse files
committed
Updated docs, added new properties to health check cluster client
1 parent 29ea862 commit acde146

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

docs/geographic_failover.rst

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,26 +342,17 @@ asyncio event loop, so please ensure that `check_health` method is async:
342342

343343
.. code-block:: python
344344
345-
from redis.asyncio.multidb.healthcheck import AbstractHealthCheck
346-
from redis.asyncio import Connection
347-
348-
class PingHealthCheck(AbstractHealthCheck):
349-
def __init__(
350-
self,
351-
health_check_probes: int = 10,
352-
health_check_delay: float = 0.1,
353-
health_check_timeout: float = 2,
354-
):
355-
super().__init__(
356-
health_check_probes=health_check_probes,
357-
health_check_delay=health_check_delay,
358-
health_check_timeout=health_check_timeout,
359-
)
345+
from redis.asyncio.multidb.healthcheck import AbstractHealthCheck, AsyncRedisClientT
346+
347+
class EchoHealthCheck(AbstractHealthCheck):
348+
"""
349+
Health check based on ECHO command.
350+
"""
360351
361-
async def check_health(self, database, connection: Connection) -> bool:
362-
await connection.send_command("PING")
352+
async def check_health(self, database, hc_client: AsyncRedisClientT) -> bool:
353+
await connection.send_command("ECHO", "healthcheck")
363354
response = await connection.read_response()
364-
return response in (b"PONG", "PONG")
355+
return response in (b"healthcheck", "healthcheck")
365356
366357
Failure Detection (Reactive Monitoring)
367358
-----------------

redis/asyncio/multidb/healthcheck.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ async def get_client(self, database) -> AsyncRedisClientT:
189189
client = AsyncRedisCluster(
190190
host=first_node.host,
191191
port=first_node.port,
192+
dynamic_startup_nodes=database.client.nodes_manager._dynamic_startup_nodes,
193+
address_remap=database.client.nodes_manager.address_remap,
194+
require_full_coverage=database.client.nodes_manager._require_full_coverage,
195+
retry=database.client.retry,
192196
**filtered_kwargs,
193197
)
194198
else:

0 commit comments

Comments
 (0)