module RubyJob::Worker

Attributes

jobstore[R]

Public Class Methods

included(base) click to toggle source
# File lib/ruby_job/worker.rb, line 6
def included(base)
  base.extend(ClassMethods)
end
jobstore=(jobstore) click to toggle source
# File lib/ruby_job/worker.rb, line 12
def jobstore=(jobstore)
  raise ArgumentError, 'argument provided is not a JobStore' unless jobstore.is_a?(JobStore)

  @jobstore = jobstore
end

Public Instance Methods

retry?(*) click to toggle source
# File lib/ruby_job/worker.rb, line 19
def retry?(*)
  false
end

Private Instance Methods

do_perform(*args) click to toggle source
# File lib/ruby_job/worker.rb, line 25
def do_perform(*args)
  @attempt ||= 1
  perform(*args)
rescue StandardError => e
  (do_retry, retry_delay) = retry?(attempt: @attempt, error: e)
  raise unless do_retry

  sleep(retry_delay || 0)
  @attempt += 1
  retry
end