Merge pull request #403 from valentinogagliardi/redis-url

ability to use a Redis connection URI - closes #402
This commit is contained in:
Ilan Steemers
2020-01-17 15:31:37 +01:00
committed by GitHub
3 changed files with 12 additions and 0 deletions
+2
View File
@@ -59,4 +59,6 @@ class Redis(Broker):
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
View File
@@ -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):
+6
View File
@@ -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: