andymccurdy/redis-py — pull request #537 by feifangit (2014-09-28 06:29:31+00:00)
Title: add url support for sentinel

Enhanced `from_url` function in utils.py. Support fetch a sentinel object or master redis node.

With the ability to get master redis node from url, other libraries based on redis-py are able to benefit from redis sentinel feature, including django-redis-cache and redis backend in celery etc.

Return sentinel object if not service_name provided in url
```python
>>> redis.from_url('sentinels://10.1.2.122:17700')
Sentinel
>>> redis.from_url('sentinels://node1:17700,node2:17700')
Sentinel
```

Return master node if service_name provided in url
```python
>>> redis.from_url('sentinels://node1:17700,node2:17700?service_name=mymaster', db=1)
StrictRedis
```

you can pass same parameters used in `Sentinel.master_for` in `master_for_args` in new `from_url`
```python
>>> redis.from_url('sentinels://node1:17700,node2:17700?service_name=mymaster', db=1, master_for_args={'redis_class':redis.Redis})
Redis
```