Made Redis bus/local bus choice more flexible

This commit is contained in:
Fabio Manganiello 2018-12-18 12:21:55 +01:00
parent 400a6fc718
commit 13463420d9

View file

@ -12,6 +12,7 @@ import traceback
from threading import Thread from threading import Thread
from .bus import Bus
from .bus.redis import RedisBus from .bus.redis import RedisBus
from .config import Config from .config import Config
from .context import register_backends from .context import register_backends
@ -120,7 +121,12 @@ class Daemon:
def start(self): def start(self):
""" Start the daemon """ """ Start the daemon """
self.bus = RedisBus(on_message=self.on_message()) redis_conf = Config.get('backend.redis')
if redis_conf:
self.bus = RedisBus(on_message=self.on_message(),
**redis_conf.get('redis_args', {}))
else:
self.bus = Bus(on_message=self.on_message())
# Initialize the backends and link them to the bus # Initialize the backends and link them to the bus
self.backends = register_backends(bus=self.bus, global_scope=True) self.backends = register_backends(bus=self.bus, global_scope=True)