18F/imls-pi-stack

Remove the queues

jadudm opened this issue · 0 comments

Currently, we have a queue abstraction that lives inside the durations.sqlite database file.

We use the queues to figure out what images need to be drawn, and what sessions need to be sent to the server. This is useful in case we lose network connectivity. We can store data locally, and the queue will tell us what still needs to be sent when the connectivity comes back.

That said, we could do this differently.

We could write all durations data to two locations:

  1. The existing durations table. This is where the data is "kept."
  2. A table called pending_durations or similar. This is data that is "queued."

Every time we process data, we write it to the durations and pending_durations tables. Then, we look at pending_durations, and try and send everything in it. If we are successful, we delete it. If we are unsuccessful, we leave it there.

In this way, we eliminate the queue. We instead have a DB that, if rows are present, need to be sent. This eliminates the need to track a list of session IDs, and instead says "this stuff all needs to go."

The image writing... is almost a useless queue. If we can't write an image (because of disk/microSD card issues), we're probably never going to be able to write the image. As a mechanism, queueing the image writing is kinda... weird. I suspect it's just a way of passing the session ID to the image writing routine.

That's something to think about, anyway, in removing queues.