Skip to content

Commit

Permalink
fix(connection): accept all parameters for redis connection [python] (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
radicevicbranko authored Mar 24, 2024
1 parent 52d4439 commit ce30192
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions python/bullmq/redis_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ def __init__(self, redisOpts: dict | str = {}):
retry_errors = [BusyLoadingError, ConnectionError, TimeoutError]

if isinstance(redisOpts, dict):
host = redisOpts.get("host") or "localhost"
port = redisOpts.get("port") or 6379
db = redisOpts.get("db") or 0
password = redisOpts.get("password") or None
username = redisOpts.get("username") or None
defaultOpts = {
"host": "localhost",
"port": 6379,
"db": 0,
"password": None,
"username": None,
}
finalOpts = {**defaultOpts, **redisOpts}

self.conn = redis.Redis(
host=host, port=port, db=db, password=password, decode_responses=True,
retry=retry, retry_on_error=retry_errors, username=username)
self.conn = redis.Redis(decode_responses=True, retry=retry, retry_on_error=retry_errors, **finalOpts)
else:
self.conn = redis.from_url(redisOpts, decode_responses=True, retry=retry,
retry_on_error=retry_errors)
Expand Down

0 comments on commit ce30192

Please sign in to comment.