Skip to content

Deliver mail asynchronously via deliver_later#5530

Merged
zachmargolis merged 8 commits intomainfrom
margolis-async-mail
Oct 22, 2021
Merged

Deliver mail asynchronously via deliver_later#5530
zachmargolis merged 8 commits intomainfrom
margolis-async-mail

Conversation

@zachmargolis
Copy link
Contributor

  • Also adds a Rubocop linter to help keep us consistent

For all we know, there's some mail permission that's missing on the worker hosts so we need to confirm this works before merging

- Also adds a Rubocop linter to help keep us consistent
Comment on lines -9 to +12
- ./lib/linters/url_options_linter.rb
- ./lib/linters/localized_validation_message_linter.rb
- ./lib/linters/mail_later_linter.rb
- ./lib/linters/redirect_back_linter.rb
- ./lib/linters/url_options_linter.rb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetizing

Copy link
Contributor

@mitchellhenke mitchellhenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Does it do retries, and do we want to limit that, e.g. so we don't send password reset emails after the code has expired?

Would we want to feature flag this?

@zachmargolis
Copy link
Contributor Author

zachmargolis commented Oct 21, 2021

Does it do retries, and do we want to limit that, e.g. so we don't send password reset emails after the code has expired?

I wasn't sure so I checked the the ActionMailer docs

deliver_later(options = {})
Enqueues the email to be delivered through Active Job. When the job runs it will send the email using deliver_now.

and then the ActiveJob docs:

10.1 Retrying or Discarding failed jobs

A failed job will not be retried, unless configured otherwise.

So my current believe is: no these will not be automatically retried.

Would we want to feature flag this?

Yeah I am open to feature flagging, do you have an approach? I'm thinking we could monkey patch on a method like deliver_now_or_later that checks the flag and routes it? intead of updating each callsite with a ternary?

@mitchellhenke
Copy link
Contributor

mitchellhenke commented Oct 21, 2021

So my current believe is: no these will not be automatically retried.

I think that's the behavior we'd want for now, so sounds good.

Yeah I am open to feature flagging, do you have an approach? I'm thinking we could monkey patch on a method like deliver_now_or_later that checks the flag and routes it? intead of updating each callsite with a ternary?

That makes sense to me, if we can subclass the mailer or something, that'd be great.

@zachmargolis
Copy link
Contributor Author

That makes sense to me, if we can subclass the mailer or something, that'd be great.

🤦 UserMailer is already our subclass --- I will use that

@zachmargolis
Copy link
Contributor Author

feature flag added in 11e64d6

- because it's called on the result of methods on ActionMailer::Base
  subclasses, not on the mailers themselves
@zachmargolis
Copy link
Contributor Author

For all we know, there's some mail permission that's missing on the worker hosts so we need to confirm this works before merging

Confirmed the worker hosts have correct SES permsision

@zachmargolis zachmargolis changed the title Delivery mail asynchronously via deliver_later Deliver mail asynchronously via deliver_later Oct 21, 2021
@zachmargolis
Copy link
Contributor Author

Admin overriding the diff coverage

@zachmargolis zachmargolis merged commit 92ffa6d into main Oct 22, 2021
@zachmargolis zachmargolis deleted the margolis-async-mail branch October 22, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants