mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-03 19:08:11 +08:00
adds info method to brokers
This commit is contained in:
@@ -62,6 +62,12 @@ class Broker(object):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def info(self):
|
||||||
|
"""
|
||||||
|
Shows the broker type
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def set_stat(self, key, value, timeout):
|
def set_stat(self, key, value, timeout):
|
||||||
"""
|
"""
|
||||||
Saves a cluster statistic to the cache provider
|
Saves a cluster statistic to the cache provider
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ class Sqs(Broker):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
def info(self):
|
||||||
|
return 'AWS SQS'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_connection(list_key=Conf.PREFIX):
|
def get_connection(list_key=Conf.PREFIX):
|
||||||
conn = boto.sqs.connect_to_region(Conf.SQS['region'],
|
conn = boto.sqs.connect_to_region(Conf.SQS['region'],
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ class Disque(Broker):
|
|||||||
if jobs:
|
if jobs:
|
||||||
self.connection.execute_command('DELJOB {}'.format(' '.join(map(str, 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
|
@staticmethod
|
||||||
def get_connection(list_key=Conf.PREFIX):
|
def get_connection(list_key=Conf.PREFIX):
|
||||||
# randomize nodes
|
# randomize nodes
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ class IronMQBroker(Broker):
|
|||||||
def ping(self):
|
def ping(self):
|
||||||
return self.connection.name == self.list_key
|
return self.connection.name == self.list_key
|
||||||
|
|
||||||
|
def info(self):
|
||||||
|
return 'IronMQ'
|
||||||
|
|
||||||
def queue_size(self):
|
def queue_size(self):
|
||||||
return self.connection.size()
|
return self.connection.size()
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ class Redis(Broker):
|
|||||||
logger.error('Can not connect to Redis server.')
|
logger.error('Can not connect to Redis server.')
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
def info(self):
|
||||||
|
info = self.connection.info('server')
|
||||||
|
return 'Redis {}'.format(info['redis_version'])
|
||||||
|
|
||||||
def set_stat(self, key, value, timeout):
|
def set_stat(self, key, value, timeout):
|
||||||
self.connection.set(key, value, timeout)
|
self.connection.set(key, value, timeout)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user