Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 7 additions and 4 deletions.
  1. +4 −1 nydus/db/routers/__init__.py
  2. +1 −1 nydus/db/routers/redis.py
  3. +2 −2 tests/test_routers.py
View
5 nydus/db/routers/__init__.py
@@ -16,6 +16,9 @@ class BaseRouter(object):
retryable = False
def get_db(self, cluster, func, *args, **kwargs):
- """Return the first entry in the cluster"""
+ """
+ Return the first entry in the cluster
+ The return value must be iterable
+ """
return range(len(cluster))
View
2 nydus/db/routers/redis.py
@@ -33,7 +33,7 @@ def get_db(self, cluster, *args, **kwargs):
return []
if not hasattr(self, 'cycler'):
self.cycler = self._get_db__round_robin(cluster)
- return self.cycler.next()
+ return [self.cycler.next()]
class ConsistentHashingRouter(BaseRouter):
View
4 tests/test_routers.py
@@ -65,11 +65,11 @@ def test_cluster_of_zero_returns_zero(self):
def test_cluster_of_one_returns_one(self):
self.cluster.hosts = {0: DummyConnection('foo')}
- self.assertEquals([0], [self.get_db(), ])
+ self.assertEquals([0], self.get_db())
def test_multi_node_cluster_returns_correct_host(self):
self.cluster.hosts = {0: DummyConnection('foo'), 1: DummyConnection('bar')}
- self.assertEquals([0, 1, 0, 1], [self.get_db(), self.get_db(), self.get_db(), self.get_db(), ])
+ self.assertEquals([[0], [1], [0], [1]], [self.get_db(), self.get_db(), self.get_db(), self.get_db(), ])
class InterfaceTest(ConsistentHashingRouterTest):

No commit comments for this range

Something went wrong with that request. Please try again.