sivulich / mqttasgi

MQTT ASGI Protocol Server
MIT License
34 stars 15 forks source link

MQTTAsgi queues deleted on unit / script reset #7

Open mzitelli97 opened 2 years ago

mzitelli97 commented 2 years ago

Mqtt asgi uses asyncio queues for communication with applications (line 333 of server.py). These could be stored outside the running instance to enable persistent queues at reset, for example using Redis. This will prevent the loss of potentially irreplaceable data if the server shutdowns for any reason.

sivulich commented 2 years ago

This can be achieved with Redis Lists it's a nice addition to make for a robust operation.

We can also add a flag in the cli to clean the list before starting (for example if the queue is filled with errors).

SootyOwl commented 1 year ago

@sivulich I'd be willing to take a shot at implementing this enhancement if we can hash out some details on it.

I'm assuming we still want to support asyncio queues (backwards compatibility, basic use) and the addition of a redis instance will be a CLI flag?

sivulich commented 1 year ago

Hey @SootyOwl, that would be great. I think that enabling through a flag would be great. Also maybe setting an ID/prefix of the queues the instance is using, so you can respawn the MQTTASGI instance in another server with the same data, and to prevent overlap when you have multiple instances running in parallel.

SootyOwl commented 1 year ago

Hi @sivulich, sure that all sounds good! Hopefully I'll be able to take a look this weekend and will open a PR for further discussion then.