platanus / potassium

A Rails application generator by Platanus, inspired by Suspenders
MIT License
232 stars 17 forks source link

Mailer queue #341

Closed difernandez closed 3 years ago

difernandez commented 3 years ago

Changes

For mails to work with sidekiq, a mailers queue must be defined. This PR adds that queue to sidekiq.yml when running create or install. This was done by adding in bg_processor a new public method, add_mailer_queue. This is used in add_sidekiq and in the mailer recipe when sidekiq is already installed at the moment of running the mailer install.

Other things in this PR:

Alternative approach

I'm not sure the way I did it is the best way, it feels like mailer and bg_processor recipes are too dependent of each other. I think there's another way of going about this that keeps the responsibility of adding the mailer queue in the mailer recipe, but again, not sure if it's better:

I haven't seen run_action used in recipes much. Would appreciate opinions on this.

Edit: I added a new commit with a refactor that uses this approach. It was mainly moving stuff around, I had to make some methods public, because inside the run_action and after you are not in the context of the recipe, so I had to access thos methods from "outside" using recipe.some_public_method. Let me know what you think

Closes #334