MQTTRegistrator
faststream.mqtt.broker.registrator.MQTTRegistrator #
Bases: Registrator['zmqtt.Message', MQTTBrokerConfig]
Includable to MQTTBroker router.
Source code in faststream/_internal/broker/registrator.py
config instance-attribute #
subscriber #
subscriber(
topic: str,
*,
qos: QoS = AT_MOST_ONCE,
shared: str | None = None,
ack_policy: AckPolicy = EMPTY,
no_reply: bool = False,
dependencies: Iterable[Dependant] = (),
parser: Optional[CustomCallable] = None,
decoder: Optional[CustomCallable] = None,
max_workers: int = 1,
persistent: bool = True,
title: str | None = None,
description: str | None = None,
include_in_schema: bool = True,
) -> MQTTDefaultSubscriber | MQTTConcurrentSubscriber
Subscribe a handler to an MQTT topic.
| PARAMETER | DESCRIPTION |
|---|---|
topic | MQTT topic filter. Wildcards TYPE: |
qos | QoS level for the subscription (0, 1, or 2). TYPE: |
shared | Optional shared subscription group name. When set, subscribes as TYPE: |
ack_policy | Acknowledgement policy for message processing. TYPE: |
no_reply | Whether to disable FastStream RPC / reply-to responses. TYPE: |
dependencies | Dependencies list to apply to the subscriber. TYPE: |
parser | Custom parser to map raw messages to FastStream ones. TYPE: |
decoder | Function to decode FastStream message bytes to Python objects. TYPE: |
max_workers | Number of workers to process messages concurrently. TYPE: |
persistent | Whether to retain the subscriber across broker restarts. TYPE: |
title | AsyncAPI subscriber object title. TYPE: |
description | AsyncAPI subscriber object description. TYPE: |
include_in_schema | Whether to include operation in AsyncAPI schema. TYPE: |
Source code in faststream/mqtt/broker/registrator.py
publisher #
publisher(
topic: str,
*,
qos: QoS = AT_MOST_ONCE,
retain: bool = False,
headers: dict[str, str] | None = None,
persistent: bool = True,
title: str | None = None,
description: str | None = None,
schema: Any | None = None,
include_in_schema: bool = True,
) -> MQTTPublisher
Create a persistent publisher object for the given MQTT topic.
| PARAMETER | DESCRIPTION |
|---|---|
topic | MQTT topic to publish to. Must not contain wildcards. TYPE: |
qos | QoS level for published messages (0, 1, or 2). TYPE: |
retain | Whether the broker should retain the last message. TYPE: |
headers | Default headers to include in every published message. TYPE: |
persistent | Whether to retain the publisher across broker restarts. TYPE: |
title | AsyncAPI publisher object title. TYPE: |
description | AsyncAPI publisher object description. TYPE: |
schema | AsyncAPI publishing message type. TYPE: |
include_in_schema | Whether to include operation in AsyncAPI schema. TYPE: |
Source code in faststream/mqtt/broker/registrator.py
include_router #
include_router(
router: MQTTRegistrator,
*,
prefix: str = "",
dependencies: Iterable[Dependant] = (),
middlewares: Sequence[BrokerMiddleware[Any, Any]] = (),
include_in_schema: bool | None = None,
) -> None
Source code in faststream/mqtt/broker/registrator.py
add_middleware #
add_middleware(
middleware: BrokerMiddleware[Any, Any],
) -> None
Append BrokerMiddleware to the end of middlewares list.
Current middleware will be used as a most inner of the stack.
Source code in faststream/_internal/broker/registrator.py
insert_middleware #
insert_middleware(
middleware: BrokerMiddleware[Any, Any],
) -> None
Insert BrokerMiddleware to the start of middlewares list.
Current middleware will be used as a most outer of the stack.