adds info method to brokers

This commit is contained in:
Ilan Steemers
2015-09-03 14:29:03 +02:00
parent b1f2143a3d
commit 01f8d9ce47
5 changed files with 20 additions and 0 deletions

View File

@@ -62,6 +62,12 @@ class Broker(object):
"""
pass
def info(self):
"""
Shows the broker type
"""
pass
def set_stat(self, key, value, timeout):
"""
Saves a cluster statistic to the cache provider

View File

@@ -46,6 +46,9 @@ class Sqs(Broker):
except Exception as e:
raise e
def info(self):
return 'AWS SQS'
@staticmethod
def get_connection(list_key=Conf.PREFIX):
conn = boto.sqs.connect_to_region(Conf.SQS['region'],

View File

@@ -32,6 +32,10 @@ class Disque(Broker):
if jobs:
self.connection.execute_command('DELJOB {}'.format(' '.join(map(str, jobs))))
def info(self):
info = self.connection.info('server')
return 'Disque {}'.format(info['disque_version'])
@staticmethod
def get_connection(list_key=Conf.PREFIX):
# randomize nodes

View File

@@ -17,6 +17,9 @@ class IronMQBroker(Broker):
def ping(self):
return self.connection.name == self.list_key
def info(self):
return 'IronMQ'
def queue_size(self):
return self.connection.size()

View File

@@ -34,6 +34,10 @@ class Redis(Broker):
logger.error('Can not connect to Redis server.')
raise e
def info(self):
info = self.connection.info('server')
return 'Redis {}'.format(info['redis_version'])
def set_stat(self, key, value, timeout):
self.connection.set(key, value, timeout)