在不重新排列排队系统的情况下,实现摘要电子邮件最优雅的方式是什么? [英] What's the most elegant way to implement a digest email without reinventing a queueing system?
问题描述
类评论
after_create:email_original_poster
def email_original_poster
UserMailer.delay.notify_author_of_comment self
end
end
然而,我的用户的一大部分不喜欢每天或每周的摘要。
实现这个最干净最优雅的方式是什么?
已经有$ code> delayed_job 运行,但这并不真的像一个 delayed_job
工作,因为我排队需要的数据被执行而不是需要执行的操作。
...而不重新排列排队系统
我知道明显的解决方案是 queued_emails
的表,当然我可以这样做。我提出这个问题的原因是,这样做是重新排列排队系统。不仅在那里有很多排队系统,但是从Percona指出的这个很好的帖子指出,不要自己滚动:
您是否实施了摘要电子邮件,是否使用 delayed_job
&你学到了什么?
如果有人想要更好的方式做更多的细节,好的概述(第二个答案):根据间隔使用电子邮件发送Ruby on Rails
I have my transactional email system setup & by default people get emails as events happen:
class Comment
after_create :email_original_poster
def email_original_poster
UserMailer.delay.notify_author_of_comment self
end
end
However instead of getting the email as-it-happens, a chunk of my users would prefer a daily or weekly digest.
What's the cleanest most elegant way to implement this?
I've already got delayed_job
running but this doesn't really feel like a delayed_job
job since I'm queueing data that needs to be acted on rather than actions that need to be executed.
...without reinventing a queueing system
I know that the obvious solution is table of queued_emails
and of course I could do that. The reason I'm asking the question is that to do so is reinventing a queueing system. Not only are there lots of queuing systems out there but as this well worded post from Percona points out, it's a good idea not to roll your own:
Have you implemented a digest email, did you use delayed_job
& what did you learn?
In case anyone wants more details on a great way to do this, there's a good overview here (second answer): Sending emails based on intervals using Ruby on Rails
这篇关于在不重新排列排队系统的情况下,实现摘要电子邮件最优雅的方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!