如何在 resque 作业完成时提醒用户 [英] How to alert user when a resque job finishes

查看:43
本文介绍了如何在 resque 作业完成时提醒用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 resque gem 处理后台作业的 ruby​​ on rails 应用程序.我有用户触发可能需要 10 分钟以上才能完成的后台作业(他们正在处理大量数据).作业完成时提醒用户的最佳方式是什么?

I have a ruby on rails app using the resque gem to process background jobs. I have users trigger background jobs that can take upwards of 10 minutes to complete (they're processing a ton of data). What is the best way to alert the user when the job has completed?

我在这里看到了关于使用resque-status,这是唯一的解决方案吗?或者是否有另一种方式通过正常的resque(我已经实现)来提醒用户?

I've seen the answer here about using resque-status, is that the only solution? Or is there another way to alert the user through normal resque (which I've already implemented)?

推荐答案

如果您打算异步通知用户,您有三个选择:

If you intend to notify a user asynchronously, you have three options:

  1. 在数据库中设置一个标志,然后在他们下次登录时更改您的 UI.(例如弹出警报视图或其他内容.)
  2. 在作业运行结束时向他们发送电子邮件.只需使用标准的 ActionMailer 工具即可.
  3. 如果您使用的是 Faye 或 Juggernaut 等发布订阅框架,请向用户推送工作已完成的通知.如果他们已登录,他们应该会立即看到.

我能想到的几乎只有这些.我个人会选择 1 和 2 的组合;完成后向他们发送电子邮件,并在他们下次登录时通知他们(并在通知中提供链接).

Those are pretty much the only things I can think of. I would personally go with a combination of 1 and 2; send them an email on completion, and notify them (and provide a link in the notification) the next time they log in.

这篇关于如何在 resque 作业完成时提醒用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆