Class: Sidekiq::RetryMonitoring

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/retry_monitoring.rb

Instance Method Summary collapse

Instance Method Details

#call(worker, params, _queue) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/sidekiq/retry_monitoring.rb', line 5

def call(worker, params, _queue)
  worker.notify(params) if should_notify?(worker, params)
rescue => e
  ::Rails.logger.error e
ensure
  yield
end

#should_notify?(worker, job) ⇒ Boolean (private)

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
# File 'lib/sidekiq/retry_monitoring.rb', line 15

def should_notify?(worker, job)
  return false unless job['retry_count']

  # retry_count is incremented after all middlewares are called

  worker.is_a?(Sidekiq::MonitoredWorker) &&
    (Integer(job['retry_count']) + 1).in?(worker.retry_limits_for_notification)
end