4
4
from dataclasses import dataclass
5
5
from datetime import datetime , timedelta
6
6
from operator import attrgetter
7
+ from ssl import SSLContext
7
8
from typing import Any , List , Optional , Tuple , Union
8
9
from uuid import uuid4
9
10
@@ -29,6 +30,7 @@ class RedisSettings:
29
30
port : int = 6379
30
31
database : int = 0
31
32
password : str = None
33
+ ssl : [bool , None , SSLContext ] = None
32
34
conn_timeout : int = 1
33
35
conn_retries : int = 5
34
36
conn_retry_delay : int = 1
@@ -183,16 +185,17 @@ async def create_pool(
183
185
addr = settings .host
184
186
185
187
async def pool_factory (* args , ** kwargs ):
186
- client = await aioredis .sentinel .create_sentinel_pool (* args , ** kwargs )
188
+ client = await aioredis .sentinel .create_sentinel_pool (* args , ssl = settings . ssl , ** kwargs )
187
189
return client .master_for (settings .sentinel_master )
188
190
189
191
else :
190
- pool_factory = functools .partial (aioredis .create_pool , create_connection_timeout = settings .conn_timeout )
192
+ pool_factory = functools .partial (
193
+ aioredis .create_pool , create_connection_timeout = settings .conn_timeout , ssl = settings .ssl
194
+ )
191
195
addr = settings .host , settings .port
192
196
193
197
try :
194
198
pool = await pool_factory (addr , db = settings .database , password = settings .password , encoding = 'utf8' )
195
-
196
199
pool = ArqRedis (pool , job_serializer = job_serializer , job_deserializer = job_deserializer )
197
200
198
201
except (ConnectionError , OSError , aioredis .RedisError , asyncio .TimeoutError ) as e :
0 commit comments