mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-20 11:28:34 +08:00
Adds custom broker configuration
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from django_q.conf import Conf
|
||||
import importlib
|
||||
|
||||
from django.core.cache import caches, InvalidCacheBackendError
|
||||
|
||||
from django_q.conf import Conf
|
||||
|
||||
|
||||
class Broker(object):
|
||||
def __init__(self, list_key=Conf.PREFIX):
|
||||
@@ -171,6 +174,12 @@ def get_broker(list_key=Conf.PREFIX):
|
||||
elif Conf.MONGO:
|
||||
from brokers import mongo
|
||||
return mongo.Mongo(list_key=list_key)
|
||||
elif Conf.BROKER:
|
||||
module, func = Conf.BROKER.rsplit('.', 1)
|
||||
m = importlib.import_module(module)
|
||||
broker = getattr(m, func)
|
||||
return broker(list_key=list)
|
||||
|
||||
# default to redis
|
||||
else:
|
||||
from brokers import redis_broker
|
||||
|
||||
Reference in New Issue
Block a user