Delayed_job 自定义失败断言?
我正在使用delayed_job作为优先级队列。我想知道如何定义失败的工作?
谢谢。
I'm using delayed_job for a priority queue. I was wondering how do i define what a failed job is?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
失败的作业是引发错误的作业。如果您希望作业失败,您只需提出错误即可。有时,如果我正在等待其他事情完成,我不会在将来使作业失败,而是将另一个作业放入队列中,并在未来 x 时间使用
run_at
。A failed job is a job that raises an error. If you want the job to fail you can simply raise an error. Sometimes, if I am waiting on something else to finish, instead of failing the job I will put another job in the queue with a
run_at
for x time in the future.失败的作业会像成功的作业一样被默认删除。但是,您可以配置 delayed_job 来保留它们,在这种情况下,failed_at 列将填充时间上次的失败。然后你只需检查 failed_at 是否为零。使用默认行为,我还没有找到一种方法来区分成功的工作和失败的工作。
Failed jobs are deleted by default, just like successful ones. However, you can configure delayed_job to keep them, in which case the failed_at column will be populated with the time of the last failure. Then you simply check if failed_at is nil or not. With the default behaviour, I haven't found a way to tell a successful job from a failed one.