44from dataclasses import dataclass
55from datetime import datetime , timedelta
66from operator import attrgetter
7+ from ssl import SSLContext
78from typing import Any , List , Optional , Tuple , Union
89from uuid import uuid4
910
@@ -29,6 +30,7 @@ class RedisSettings:
2930 port : int = 6379
3031 database : int = 0
3132 password : str = None
33+ ssl : [bool , None , SSLContext ] = None
3234 conn_timeout : int = 1
3335 conn_retries : int = 5
3436 conn_retry_delay : int = 1
@@ -183,16 +185,17 @@ async def create_pool(
183185 addr = settings .host
184186
185187 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 )
187189 return client .master_for (settings .sentinel_master )
188190
189191 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+ )
191195 addr = settings .host , settings .port
192196
193197 try :
194198 pool = await pool_factory (addr , db = settings .database , password = settings .password , encoding = 'utf8' )
195-
196199 pool = ArqRedis (pool , job_serializer = job_serializer , job_deserializer = job_deserializer )
197200
198201 except (ConnectionError , OSError , aioredis .RedisError , asyncio .TimeoutError ) as e :
0 commit comments