Permalink
Browse files

move flake8 install to Makefile

  • Loading branch information...
1 parent 1902351 commit 8b1f607d2fde680b3b4cbffde63b3f68ac8fdc02 @dcramer dcramer committed Oct 3, 2012
Showing with 64 additions and 1 deletion.
  1. +0 −1 .travis.yml
  2. +1 −0 Makefile
  3. 0 src/sentry/pool/__init__.py
  4. +19 −0 src/sentry/pool/base.py
  5. +44 −0 src/sentry/pool/redis.py
View
@@ -13,7 +13,6 @@ install:
- pip install mysql-python
- pip install psycopg2
- pip install -q Django==$DJANGO --use-mirrors
- - pip install flake8 --use-mirrors
- pip install -q -e . --use-mirrors
script:
- make test
View
@@ -44,6 +44,7 @@ watch:
watchr -e "watch('src/bootstrap/.*\.less') { system 'make static' }"
test:
+ pip install flake8 --use-mirrors
cd src && flake8 --exclude=migrations --ignore=E501,E225,E121,E123,E124,E125,E127,E128 --exit-zero sentry || exit 1
python setup.py test
No changes.
View
@@ -0,0 +1,19 @@
+"""
+sentry.pool.base
+~~~~~~~~~~~~~~~~
+
+:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
+:license: BSD, see LICENSE for more details.
+"""
+
+
+class Pool(object):
+ def __init__(self, keyspace):
+ self.keyspace = keyspace
+ self.queue = []
+
+ def put(self, item):
+ self.queue.append(item)
+
+ def get(self):
+ return self.queue.pop()
View
@@ -0,0 +1,44 @@
+"""
+sentry.pool.redis
+~~~~~~~~~~~~~~~~~
+
+:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
+:license: BSD, see LICENSE for more details.
+"""
+from nydus.db import create_cluster
+
+
+class RedisCappedPool(object):
+ """
+ Stores entries in a capped set with pairing entries in a secondary key.
+ """
+ key_expire = 60 * 60 # 1 hour
+
+ def __init__(self, keyspace, size=1000, hosts=None, router='nydus.db.routers.keyvalue.PartitionRouter', **options):
+ super(RedisCappedPool, self).__init__(**options)
+ if hosts is None:
+ hosts = {
+ 0: {} # localhost / default
+ }
+ self.conn = create_cluster({
+ 'engine': 'nydus.db.backends.redis.Redis',
+ 'router': router,
+ 'hosts': hosts,
+ })
+
+ def put(self, item):
+ """
+ Stores the item in a unique key and adds its identifier to a set:
+
+ SADD keyspace "{}:{}".format(item['id'], item['checksum'])
+ SET "{}:{}".format(keyspace, item['checksum']) item
+
+ The size of the set is also checked and cleaned up as needd.
+ """
+ self.queue.append(item)
+
+ def get(self):
+ """
+ SPOP keyspace
+ """
+ return self.queue.pop()

0 comments on commit 8b1f607

Please sign in to comment.