mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
rename API to death handlers for consistency
This commit is contained in:
parent
87fc9285a5
commit
cdf6430739
5 changed files with 16 additions and 16 deletions
|
@ -5,7 +5,7 @@
|
|||
5.1.0
|
||||
-----------
|
||||
|
||||
- **NEW** Global failure handlers - called when your job exhausts all
|
||||
- **NEW** Global death handlers - called when your job exhausts all
|
||||
retries and dies. Now you can take action when a job fails permanently. [#3721]
|
||||
- **NEW** Enable ActiveRecord query cache within jobs by default [#3718, sobrinho]
|
||||
This will prevent duplicate SELECTS; cache is cleared upon any UPDATE/INSERT/DELETE.
|
||||
|
|
|
@ -25,7 +25,7 @@ module Sidekiq
|
|||
poll_interval_average: nil,
|
||||
average_scheduled_poll_interval: 5,
|
||||
error_handlers: [],
|
||||
failure_handlers: [],
|
||||
death_handlers: [],
|
||||
lifecycle_events: {
|
||||
startup: [],
|
||||
quiet: [],
|
||||
|
@ -158,22 +158,22 @@ module Sidekiq
|
|||
end
|
||||
|
||||
def self.default_retries_exhausted=(prok)
|
||||
logger.info { "default_retries_exhausted is deprecated, please use `config.failure_handlers << -> {|job, ex| }`" }
|
||||
logger.info { "default_retries_exhausted is deprecated, please use `config.death_handlers << -> {|job, ex| }`" }
|
||||
return nil unless prok
|
||||
failure_handlers << prok
|
||||
death_handlers << prok
|
||||
end
|
||||
|
||||
##
|
||||
# A failure handler is called when all retries for a job have been exhausted and
|
||||
# the job must be killed or dropped. It's the notification to your application
|
||||
# that this job will not finish without manual intervention.
|
||||
# Death handlers are called when all retries for a job have been exhausted and
|
||||
# the job dies. It's the notification to your application
|
||||
# that this job will not succeed without manual intervention.
|
||||
#
|
||||
# Sidekiq.configure_server do |config|
|
||||
# config.failure_handlers << -> (job, ex) do
|
||||
# config.death_handlers << ->(job, ex) do
|
||||
# end
|
||||
# end
|
||||
def self.failure_handlers
|
||||
options[:failure_handlers]
|
||||
def self.death_handlers
|
||||
options[:death_handlers]
|
||||
end
|
||||
|
||||
def self.load_json(string)
|
||||
|
|
|
@ -670,7 +670,7 @@ module Sidekiq
|
|||
job = Sidekiq.load_json(message)
|
||||
r = RuntimeError.new("Job killed by API")
|
||||
r.set_backtrace(caller)
|
||||
Sidekiq.failure_handlers.each do |handle|
|
||||
Sidekiq.death_handlers.each do |handle|
|
||||
handle.call(job, r)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -178,11 +178,11 @@ module Sidekiq
|
|||
handle_exception(e, { context: "Error calling retries_exhausted", job: msg })
|
||||
end
|
||||
|
||||
Sidekiq.failure_handlers.each do |handler|
|
||||
Sidekiq.death_handlers.each do |handler|
|
||||
begin
|
||||
handler.call(msg, exception)
|
||||
rescue => e
|
||||
handle_exception(e, { context: "Error calling retries_exhausted", job: msg })
|
||||
handle_exception(e, { context: "Error calling death handler", job: msg })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -157,8 +157,8 @@ class TestRetryExhausted < Sidekiq::Test
|
|||
|
||||
exhausted_job = nil
|
||||
exhausted_exception = nil
|
||||
Sidekiq.failure_handlers.clear
|
||||
Sidekiq.failure_handlers << proc do |job, ex|
|
||||
Sidekiq.death_handlers.clear
|
||||
Sidekiq.death_handlers << proc do |job, ex|
|
||||
exhausted_job = job
|
||||
exhausted_exception = ex
|
||||
end
|
||||
|
@ -173,7 +173,7 @@ class TestRetryExhausted < Sidekiq::Test
|
|||
assert exhausted_job
|
||||
assert_equal raised_error, exhausted_exception
|
||||
ensure
|
||||
Sidekiq.failure_handlers.clear
|
||||
Sidekiq.death_handlers.clear
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue