Skip to content
Browse files

Merge pull request #2 from disqus/rrr2

round robin router returned an int, not a list
  • Loading branch information...
2 parents 07b8eff + fac1b0f commit bde33b01c61bd67709ea32f1ca5cbc7342b90ae4 @mikeclarke mikeclarke committed Feb 17, 2012
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):

0 comments on commit bde33b0

Please sign in to comment.
Something went wrong with that request. Please try again.