문제

I have a Rufus "every job" that runs periodically, but sometimes it may fail to perform it's task.

On failure, I would like to reschedule a retry soon rather than wait until the next cycle.

class PollProducts

  def initialize()
  end

  def call(job)
    puts "Updating products"

    begin
      # Do something that might fail
      raise if rand(3) == 1
    rescue Exception => e
      puts "Request failed - recheduling: #{e}"
      # job.in("5s") <-- What can I do?
    end
  end
end

scheduler.every '6h', PollProducts.new, :first_in => '5s', :blocking => true

Is this possible?

도움이 되었습니까?

해결책

Ok this worked for me:

job.scheduler.in '5s', self
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top