redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
19.95k stars 2.36k forks source link

specify custom health check func via HeartbeatFn option #2940

Open strobil opened 6 months ago

strobil commented 6 months ago

The current implementation of the Redis ring does not support specifying custom shard health check rules. We use a Redis shard to distribute the load across multiple Redis slave instances. However, if any shard encounters replication issues, the Redis ring continues to utilize this shard because it responds to ping requests successfully. Thus, the Redis ring does not remove the malfunctioning shard, even though it is inconsistent.

This pull request proposes adding a HeartbeatFn option to the RingOptions, which can be configured during ring construction. This addition enables the definition of custom health check logic, such as checks based on the current replication status of the shard.