kopia lustrzana https://github.com/Yakifo/amqtt
Change context init
rodzic
22c7ef674e
commit
3147dee4bd
|
@ -116,8 +116,9 @@ class BrokerContext(BaseContext):
|
||||||
BrokerContext is used as the context passed to plugins interacting with the broker.
|
BrokerContext is used as the context passed to plugins interacting with the broker.
|
||||||
It act as an adapter to broker services from plugins developed for HBMQTT broker
|
It act as an adapter to broker services from plugins developed for HBMQTT broker
|
||||||
"""
|
"""
|
||||||
def __init__(self, loop=None):
|
def __init__(self):
|
||||||
super().__init__(loop)
|
super().__init__()
|
||||||
|
self.config = None
|
||||||
|
|
||||||
|
|
||||||
class Broker:
|
class Broker:
|
||||||
|
@ -177,7 +178,9 @@ class Broker:
|
||||||
self.sys_handle = None
|
self.sys_handle = None
|
||||||
|
|
||||||
# Init plugins manager
|
# Init plugins manager
|
||||||
self.plugins_manager = PluginManager('hbmqtt.broker.plugins', BrokerContext(self._loop), self._loop)
|
context = BrokerContext()
|
||||||
|
context.config = self.config
|
||||||
|
self.plugins_manager = PluginManager('hbmqtt.broker.plugins', context, self._loop)
|
||||||
|
|
||||||
def _build_listeners_config(self, broker_config):
|
def _build_listeners_config(self, broker_config):
|
||||||
self.listeners_config = dict()
|
self.listeners_config = dict()
|
||||||
|
|
|
@ -38,8 +38,9 @@ class ClientContext(BaseContext):
|
||||||
ClientContext is used as the context passed to plugins interacting with the client.
|
ClientContext is used as the context passed to plugins interacting with the client.
|
||||||
It act as an adapter to client services from plugins
|
It act as an adapter to client services from plugins
|
||||||
"""
|
"""
|
||||||
def __init__(self, client):
|
def __init__(self):
|
||||||
super().__init__(client._loop)
|
super().__init__()
|
||||||
|
self.config = None
|
||||||
|
|
||||||
|
|
||||||
class MQTTClient:
|
class MQTTClient:
|
||||||
|
@ -89,7 +90,9 @@ class MQTTClient:
|
||||||
self._connection_closed_future = None
|
self._connection_closed_future = None
|
||||||
|
|
||||||
# Init plugins manager
|
# Init plugins manager
|
||||||
self.plugins_manager = PluginManager('hbmqtt.client.plugins', ClientContext(self))
|
context = ClientContext()
|
||||||
|
context.config = self.config
|
||||||
|
self.plugins_manager = PluginManager('hbmqtt.client.plugins', context)
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|
|
@ -22,11 +22,8 @@ def get_plugin_manager(namespace):
|
||||||
|
|
||||||
|
|
||||||
class BaseContext:
|
class BaseContext:
|
||||||
def __init__(self, loop=None):
|
def __init__(self):
|
||||||
if loop is not None:
|
self.loop = None
|
||||||
self._loop = loop
|
|
||||||
else:
|
|
||||||
self._loop = asyncio.get_event_loop()
|
|
||||||
self.logger = None
|
self.logger = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,6 +45,7 @@ class PluginManager:
|
||||||
self.context = BaseContext()
|
self.context = BaseContext()
|
||||||
else:
|
else:
|
||||||
self.context = context
|
self.context = context
|
||||||
|
context.loop = loop
|
||||||
self._plugins = []
|
self._plugins = []
|
||||||
self._load_plugins(namespace)
|
self._load_plugins(namespace)
|
||||||
self._fired_events = []
|
self._fired_events = []
|
||||||
|
|
Ładowanie…
Reference in New Issue