Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to use a Redis connection URI - closes #402 #403

Merged
merged 3 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions django_q/brokers/redis_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ def get_stats(self, pattern):
def get_connection(list_key=Conf.PREFIX):
if django_redis and Conf.DJANGO_REDIS:
return django_redis.get_redis_connection(Conf.DJANGO_REDIS)
if isinstance(Conf.REDIS, str):
return redis.from_url(Conf.REDIS)
return redis.StrictRedis(**Conf.REDIS)
4 changes: 4 additions & 0 deletions django_q/tests/test_brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def test_redis(monkeypatch):
broker = get_broker()
with pytest.raises(Exception):
broker.ping()
monkeypatch.setattr(Conf, 'REDIS', 'redis://127.0.0.1:7799')
broker = get_broker()
with pytest.raises(Exception):
broker.ping()


def test_custom(monkeypatch):
Expand Down
6 changes: 6 additions & 0 deletions docs/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ Connection settings for Redis. Defaults::
}
}

It's also possible to use a Redis connection URI::

Q_CLUSTER = {
'redis': 'redis://h:asdfqwer1234asdf@ec2-111-1-1-1.compute-1.amazonaws.com:111'
}

For more information on these settings please refer to the `Redis-py <https://github.com/andymccurdy/redis-py>`__ documentation

.. _django_redis:
Expand Down