Skip to content

Commit

Permalink
Allow connection_pool to be set in RedisSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-goo committed Jul 28, 2024
1 parent 3f865a6 commit 6048460
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions arq/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RedisSettings:
Used by :func:`arq.connections.create_pool` and :class:`arq.worker.Worker`.
"""

connection_pool: Optional[ConnectionPool] = None
host: Union[str, List[Tuple[str, int]]] = 'localhost'
port: int = 6379
unix_socket_path: Optional[str] = None
Expand Down Expand Up @@ -251,6 +252,7 @@ def pool_factory(*args: Any, **kwargs: Any) -> ArqRedis:
else:
pool_factory = functools.partial(
ArqRedis,
pool_or_conn=settings.connection_pool,
host=settings.host,
port=settings.port,
unix_socket_path=settings.unix_socket_path,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_settings_changed():
settings = RedisSettings(port=123)
assert settings.port == 123
assert (
"RedisSettings(host='localhost', port=123, unix_socket_path=None, database=0, username=None, password=None, "
"RedisSettings(connection_pool=None, host='localhost', port=123, unix_socket_path=None, database=0, username=None, password=None, "
"ssl=False, ssl_keyfile=None, ssl_certfile=None, ssl_cert_reqs='required', ssl_ca_certs=None, "
'ssl_ca_data=None, ssl_check_hostname=False, conn_timeout=1, conn_retries=5, conn_retry_delay=1, '
"max_connections=None, sentinel=False, sentinel_master='mymaster', "
Expand Down Expand Up @@ -203,6 +203,7 @@ def test_import_string_invalid_missing():
def test_settings_plain():
settings = RedisSettings()
assert asdict(settings) == {
'connection_pool': None,
'host': 'localhost',
'port': 6379,
'unix_socket_path': None,
Expand Down Expand Up @@ -232,6 +233,7 @@ def test_settings_from_socket_dsn():
settings = RedisSettings.from_dsn('unix:///run/redis/redis.sock')
# insert_assert(asdict(settings))
assert asdict(settings) == {
'connection_pool': None,
'host': 'localhost',
'port': 6379,
'unix_socket_path': '/run/redis/redis.sock',
Expand Down

0 comments on commit 6048460

Please sign in to comment.