diff --git a/CHANGELOG.md b/CHANGELOG.md index 827ad64..8c9949d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 3.5.0 (2015-12-11) + +* Allow options to be passed down to the connection pool. + ## 3.4.0 (2015-06-16) * Allow a Redis connection to be passed in the Leaderboard initializer using the `redis_connection` option. diff --git a/leaderboard/leaderboard.py b/leaderboard/leaderboard.py index 728cd54..c784398 100644 --- a/leaderboard/leaderboard.py +++ b/leaderboard/leaderboard.py @@ -14,13 +14,14 @@ def grouper(n, iterable, fillvalue=None): class Leaderboard(object): - VERSION = '3.4.0' + VERSION = '3.5.0' DEFAULT_PAGE_SIZE = 25 DEFAULT_REDIS_HOST = 'localhost' DEFAULT_REDIS_PORT = 6379 DEFAULT_REDIS_DB = 0 DEFAULT_MEMBER_DATA_NAMESPACE = 'member_data' DEFAULT_GLOBAL_MEMBER_DATA = False + DEFAULT_POOLS = {} ASC = 'asc' DESC = 'desc' MEMBER_KEY = 'member' @@ -29,7 +30,7 @@ class Leaderboard(object): RANK_KEY = 'rank' @classmethod - def pool(self, host, port, db, pools={}): + def pool(self, host, port, db, pools={}, **options): ''' Fetch a redis conenction pool for the unique combination of host and port. Will create a new one if there isn't one already. @@ -37,7 +38,7 @@ def pool(self, host, port, db, pools={}): key = (host, port, db) rval = pools.get(key) if not isinstance(rval, ConnectionPool): - rval = ConnectionPool(host=host, port=port, db=db) + rval = ConnectionPool(host=host, port=port, db=db, **options) pools[key] = rval return rval @@ -77,7 +78,7 @@ def __init__(self, leaderboard_name, **options): redis_connection = self.options.pop('redis_connection', None) if redis_connection: - # allow the developer to pass a raw redis connection and + # allow the developer to pass a raw redis connection and # we will use it directly instead of creating a new one self.redis_connection = redis_connection else: @@ -88,7 +89,9 @@ def __init__(self, leaderboard_name, **options): self.options['connection_pool'] = self.pool( self.options.pop('host', self.DEFAULT_REDIS_HOST), self.options.pop('port', self.DEFAULT_REDIS_PORT), - self.options.pop('db', self.DEFAULT_REDIS_DB) + self.options.pop('db', self.DEFAULT_REDIS_DB), + self.options.pop('pools', self.DEFAULT_POOLS), + **self.options ) self.redis_connection = Redis(**self.options) diff --git a/setup.py b/setup.py index 88aa773..0211ea7 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name = 'leaderboard', - version = "3.4.0", + version = "3.5.0", author = 'David Czarnecki', author_email = "dczarnecki@agoragames.com", packages = ['leaderboard'], diff --git a/test/leaderboard/leaderboard_test.py b/test/leaderboard/leaderboard_test.py index 9b2f8b4..8db8f36 100644 --- a/test/leaderboard/leaderboard_test.py +++ b/test/leaderboard/leaderboard_test.py @@ -18,7 +18,7 @@ def tearDown(self): Leaderboard.MEMBER_DATA_KEY = 'member_data' def test_version(self): - Leaderboard.VERSION.should.equal('3.4.0') + Leaderboard.VERSION.should.equal('3.5.0') def test_init_with_defaults(self): 'name'.should.equal(self.leaderboard.leaderboard_name)