Litestar-mqtt is porting of Fastapi-mqtt for the Litestar framework.
For more information about MQTT, please refer to the Fastapi-mqtt MQTT documentation.
As Fastapi-mqtt, Litestar-mqtt wraps around gmqtt module.
Litestar-mqtt implements the same feature of Fastapi-mqtt and also:
- Load configurations via
.env
file
MQTT_HOST="mqtt-dashboard.com"
$ pip install litestar-mqtt
or
$ poetry add litestar-mqtt
Litestar-mqtt must be hooked to the on_startup
and on_shutdown
handlers.
app = Litestar(
route_handlers=[test_func],
on_startup=[lite_mqtt.startup],
on_shutdown=[lite_mqtt.shutdown],
)