mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-19 02:48:16 +08:00
adds info method to brokers
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user