class Sidekiq::Middleware::Server::Seize
Public Instance Methods
call(worker, job, queue) { || ... }
click to toggle source
# File lib/sidekiq/middleware/server/seize.rb, line 11 def call(worker, job, queue) yield rescue StandardError => e options = worker.sidekiq_options_hash || {} bubble_exception(options, job, e) attempt_retry(worker, job, queue, e) end
Private Instance Methods
bubble_exception(options, job, e)
click to toggle source
# File lib/sidekiq/middleware/server/seize.rb, line 21 def bubble_exception(options, job, e) raise e unless in_seize_mode?(options) raise e unless retry_allowed?(options) raise e unless seize_class?(options, e) retry_count = job['retry_count'] || 0 last_try = retry_count == max_attempts_for(options) - 1 raise e if last_try end
in_seize_mode?(options)
click to toggle source
# File lib/sidekiq/middleware/server/seize.rb, line 37 def in_seize_mode?(options) !options['seize'].nil? && options['seize'] == true end
max_attempts_for(options)
click to toggle source
# File lib/sidekiq/middleware/server/seize.rb, line 51 def max_attempts_for(options) if options['retry'].is_a?(Integer) options['retry'] else @max_retries end end
retry_allowed?(options)
click to toggle source
# File lib/sidekiq/middleware/server/seize.rb, line 31 def retry_allowed?(options) return false if !options['retry'].nil? && options['retry'] == false return false if !options['retry'].nil? && options['retry'] == 0 true end
seize_class?(options, e)
click to toggle source
# File lib/sidekiq/middleware/server/seize.rb, line 41 def seize_class?(options, e) return true if options['seize_exceptions_classes'].nil? options['seize_exceptions_classes'].each do |klass| return true if klass == e.class end false end