nesquena / backburner

Simple and reliable beanstalkd job queue for ruby
http://nesquena.github.com/backburner
MIT License
428 stars 68 forks source link

Is there any way to call a method when the job is buried ? #97

Closed MhdSyrwan closed 8 years ago

MhdSyrwan commented 9 years ago

As mentioned here, the on_failure hook is called when an exception is called (job failed) so if the max_retry_count was 3 it will be called 3 times. Is there any way to call a method when the job is buried ?

Thanks in advance

contentfree commented 9 years ago

@nesquena If you can pull in PR #104 then we should be able to close this.

@MhdSyrwan: Once the PR is pulled in you'll be able to define hooks like this:

class MyJob
  # This hook is called only when the job is buried
  def self.on_bury_log(*args)
    # Do something
  end

  # This hook is called when the failed job is retried (and never when it's buried)
  def self.on_retry_log(retry_count, delay, *args)
    # Do something else
  end
end
MhdSyrwan commented 9 years ago

Great, Much Appreciated :+1:

contentfree commented 9 years ago

@nesquena This may be closed since #104 has been merged in. (@MhdSyrwan: You can close it, too, if you get to it first)

nesquena commented 8 years ago

Thanks