Delayed Job: Configure run_at and max_attempts for a specific job

与世无争的帅哥 提交于 2019-12-03 12:32:44

I figured it out by looking through delayed_job source code. This is not documented anywhere in their docs.

Here's what I did:

class MyCustomJob < Struct.new(:param1, :param2)
  def perform
    # do something
  end

  # attempts and time params are required by delayed_job
  def reschedule_at(time, attempts)
    30.seconds.from_now
  end

  def max_attempts
    50
  end
end

Hope this helps someone in the future.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!