-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc fixes to allow dynamic mailer name and dynamic wait while sendin… #429
Conversation
I actually just commited a fix here: 8da57f8 Is there a case this doesn't handle? |
This may work for the dynami mailer, but not for the wait time. |
Can you provide an example? |
This is what I have in my actual prod code. The reason is to prevent aws from getting flooded, which results in throttling errors. So we need to delay the sending of emails. However when sending a bunch of emails, we cant use the same delay, we need to spread the delay over some period, by randomizing it, so that aws does not get flooded. Hope this makes sense deliver_by :email do |config| def email_delay(_notification = nil) |
I agree with your changes in 8da57f8, can replace the one I suggested, for dynamic mailer. But you need the other change for dynamic wait |
Also note that in version < 2 I could do the following And the delay would be dynamic, this is the prob Im trying to solve above. |
Wait should already work, but it will be evaluated against methods in the class MyNotifier < Noticed::Event
deliver_by :email do |config|
config.mailer = :mailer_name
config.method = :email_method
config.params = :email_data
config.wait = :email_delay
end
notification_methods do
def email_delay(_notification = nil)
# Randomize the delay so we dont flood aws SES
delay_seconds = entity.entity_setting.email_delay_seconds
delay_seconds = delay_seconds.positive? ? rand(1..delay_seconds) : rand(1..300)
Rails.env.development? ? 0 : delay_seconds
end
end
end |
Makes sense, thank you for clarifying. Appreciate it.
…On Thu, 21 Mar 2024 at 02:07, Chris Oliver ***@***.***> wrote:
Wait should already work, but it will be evaluated against methods in the
notification_methods block since it would apply to the individual
recipients.
—
Reply to this email directly, view it on GitHub
<#429 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFOFXNEMQCQRX7NRG6FQRLYZHXPVAVCNFSM6AAAAABFAFMSUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJQGU3TQNBUGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
…g emails
Pull Request
Summary:
These changes enable for mailer and wait to take method names as symbols
Related Issue:
Description:
Its a pretty simple change
Testing:
Ive run my applications tests against this, but have not written any new tests specifically for these changes.
Screenshots (if applicable):
Checklist:
Additional Notes: