mate.integration.bridge module¶
- class mate.integration.bridge.Bridge(broker_host: str, broker_port: int, *args: Any, **kwargs: Any)¶
Bases:
paho.mqtt.client.Client
- Parameters
broker_host (str) –
broker_port (int) –
args (Any) –
kwargs (Any) –
- Return type
None
- handle(*topics: str)¶
A decorator for registering type-aware message handlers.
This decorator takes as arguments any number of topics (topic wildcards) which the decorated handler should subscribe to.
- The decorated handler function should take exactly two arguments:
The specific topic on which a given message came in on.
- The message itself.
If no type annotation is provided for this argument, the raw message is passed in.
If a type annotation is provided for this argument, and that type is a pydantic model, the message will be validated against that type, and the parsed model will be passed into the handler. If validation fails, the message is dropped.
- Parameters
topics (str) –
- listen() None ¶
Start listening for messages from the configured broker.
- Return type
None
- on_connect(*_args: Any) None ¶
If implemented, called when the broker responds to our connection request.
- Parameters
_args (Any) –
- Return type
None
- send(topic: str, message: str) None ¶
Send a single message on a given topic.
- Parameters
topic (str) –
message (str) –
- Return type
None
- mate.integration.bridge.handle_all(_topic: str, message) None ¶
- Parameters
_topic (str) –
- Return type
None
- mate.integration.bridge.handle_challenge_broker_target(_topic: str, target: mate_common.models.integration.Target) None ¶
- Parameters
_topic (str) –
target (mate_common.models.integration.Target) –
- Return type
None
- mate.integration.bridge.handle_decls(_topic: str, message: mate_common.models.integration.Decl) None ¶
- Parameters
_topic (str) –
message (mate_common.models.integration.Decl) –
- Return type
None
- mate.integration.bridge.initialize() None ¶
Initialize the MQTT client.
Necessary for both sending and receiving messages.
- Return type
None