Class: Shoryuken::Middleware::Server::ExponentialBackoffRetry

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/shoryuken/middleware/server/exponential_backoff_retry.rb

Instance Method Summary collapse

Methods included from Util

#elapsed, #fire_event, #logger, #unparse_queues, #watchdog, #worker_name

Instance Method Details

#call(worker, queue, sqs_msg, body) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/shoryuken/middleware/server/exponential_backoff_retry.rb', line 7

def call(worker, queue, sqs_msg, body)
  started_at = Time.now
  yield
rescue
  retry_intervals = Array(worker.class.get_shoryuken_options['retry_intervals'])

  if retry_intervals.empty? || !handle_failure(sqs_msg, started_at, retry_intervals)
    # Re-raise the exception if the job is not going to be exponential backoff retried.
    # This allows custom middleware (like exception notifiers) to be aware of the unhandled failure.
    raise
  end
end