Skip to content

Commit bef78ae

Browse files
committed
added valkey sentinel support
1 parent c4ebe16 commit bef78ae

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scheduler/connection_types.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
from typing import Union, Dict, Tuple, Type
22

33
import redis
4-
import valkey
4+
try:
5+
import valkey
6+
except ImportError:
7+
valkey = redis
58

69
from scheduler.settings import Broker
710

811
ConnectionErrorType = Union[redis.ConnectionError, valkey.ConnectionError]
9-
ConnectionType = Union[redis.Redis, valkey.Valkey]
12+
ConnectionType = Union[redis.Redis, valkey.Redis]
1013
PipelineType = Union[redis.client.Pipeline, valkey.client.Pipeline]
1114
RedisSentinel = redis.sentinel.Sentinel
15+
ValkeySentinel = valkey.sentinel.Sentinel
1216

1317
BrokerConnectionClass: Dict[Tuple[Broker, bool], Type] = {
1418
# Map of (Broker, Strict flag) => Connection Class
1519
(Broker.REDIS, False): redis.Redis,
16-
(Broker.VALKEY, False): valkey.Valkey,
20+
(Broker.VALKEY, False): valkey.Redis,
1721
(Broker.REDIS, True): redis.StrictRedis,
1822
(Broker.VALKEY, True): valkey.StrictValkey,
1923
}

0 commit comments

Comments
 (0)