Open mzitelli97 opened 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).
@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?
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.
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.
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.