Please sign in to comment.
Improve consistent hashing router.
Summary: This change makes a couple improvements to routers to help the consistent hashing router. 1. Changes from using the host of the connection to using a new connection property called "identifier" to identify the connection in the consistent hash. This allows multiple connections on the same hostname to both occur in the hash. 2. A Cluster object is more stategic in when it asks for retries from the router. At present routers only support retry on a single host, but retryable routers may return more than one host. The Cluster object now will check the len() of the hosts from the router's get_db() call and will only do the retryable_execute if that len is 1. Routers are only supposed to return 1 host after a call to get_db() with a retry_for kwarg, but in case they do not the check and raised exception is still left in. Test Plan: The still passing existing tests and new tests. Reviewers: dcramer, tail CC:
- Loading branch information...
Showing with 80 additions and 39 deletions.
- +6 −1 nydus/contrib/django/__init__.py
- +7 −6 nydus/db/__init__.py
- +3 −2 nydus/db/backends/__init__.py
- +6 −0 nydus/db/backends/redis.py
- +14 −9 nydus/db/routers/redis.py
- +6 −0 tests/test_backends/test_django.py
- +3 −0 tests/test_backends/test_redis.py
- +15 −5 tests/test_connections.py
- +20 −16 tests/test_routers.py