Minion is a handy module.

In a project that I’m on at the moment I’m managing some front-end stuff that is functional to produce emails with PDF attachments to send to specific recipients, possibly with scheduling.

In this, having a backend that takes care to do the heavy lifting while the frontend is busy with the user is very handy. And Minion makes this possible in a very unobstrusive way.

So, in my setup I’m doing this:

  • save an “order” to send an email at a certain (future) time from the frontend, saving it inside the database;
  • place a task enqueue_emails regularly in Minion, to get all emails that can be sent because they passed their send_after date;
  • in this job, create a task for each email to be sent, again in Minion.

I’m using Mojolicious for the frontend-ish stuff anyway (it’s the API backend for the presentation frontend, that will be something in Javascript probably), so it should not be a problem to schedule a regular task to enqueue new emails.

It comes with a handy plugin that adds a /minion endpoint in a Mojolicious application, allowing to see how is the queue going. Interesting, although the fan in my PC started pretty soon because the page asks for continuos updates (makes sense but still…).

Another advantage is that it can be supported both by a Postgresql and a SQLite database, which is very handy.

Stay safe!

Comments? Octodon, , GitHub, Reddit, or drop me a line!