Module: RescueLikeAPro::ActiveJob::ClassMethods

Defined in:
lib/rescue_like_a_pro/active_job.rb

Instance Method Summary collapse

Instance Method Details

#discard_on(*exceptions, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/rescue_like_a_pro/active_job.rb', line 23

def discard_on(*exceptions, &block)
  exception_map = exceptions.each_with_object({}) do |exception, h|
    h[exception.to_s] = { action: :discard_on, handler: block }
  end
  self.rescue_pro_rules = rescue_pro_rules.merge exception_map
end

#on_discard(&block) ⇒ Object



34
35
36
# File 'lib/rescue_like_a_pro/active_job.rb', line 34

def on_discard(&block)
  self.discard_handler = block
end

#on_retries_exhausted(&block) ⇒ Object



30
31
32
# File 'lib/rescue_like_a_pro/active_job.rb', line 30

def on_retries_exhausted(&block)
  self.retries_exhausted_handler = block
end

#retry_on(*exceptions, wait: 3.seconds, attempts: 5, queue: nil, priority: nil, jitter: nil, &block) ⇒ Object



16
17
18
19
20
21
# File 'lib/rescue_like_a_pro/active_job.rb', line 16

def retry_on(*exceptions, wait: 3.seconds, attempts: 5, queue: nil, priority: nil, jitter: nil, &block)
  exception_map = exceptions.each_with_object({}) do |exception, h|
    h[exception.to_s] = { action: :retry_on, wait: wait, attempts: attempts, queue: queue, priority: priority, jitter: jitter, handler: block }
  end
  self.rescue_pro_rules = rescue_pro_rules.merge exception_map
end