|
4 | 4 | require "active_support/core_ext/integer/inflections"
|
5 | 5 |
|
6 | 6 | class DefaultsError < StandardError; end
|
| 7 | +class FirstRetryableErrorOfTwo < StandardError; end |
| 8 | +class SecondRetryableErrorOfTwo < StandardError; end |
7 | 9 | class LongWaitError < StandardError; end
|
8 | 10 | class ShortWaitTenAttemptsError < StandardError; end
|
9 | 11 | class ExponentialWaitTenAttemptsError < StandardError; end
|
10 | 12 | class CustomWaitTenAttemptsError < StandardError; end
|
11 | 13 | class CustomCatchError < StandardError; end
|
12 | 14 | class DiscardableError < StandardError; end
|
| 15 | +class FirstDiscardableErrorOfTwo < StandardError; end |
| 16 | +class SecondDiscardableErrorOfTwo < StandardError; end |
13 | 17 | class CustomDiscardableError < StandardError; end
|
14 | 18 |
|
15 | 19 | class RetryJob < ActiveJob::Base
|
16 | 20 | retry_on DefaultsError
|
| 21 | + retry_on FirstRetryableErrorOfTwo, SecondRetryableErrorOfTwo |
17 | 22 | retry_on LongWaitError, wait: 1.hour, attempts: 10
|
18 | 23 | retry_on ShortWaitTenAttemptsError, wait: 1.second, attempts: 10
|
19 | 24 | retry_on ExponentialWaitTenAttemptsError, wait: :exponentially_longer, attempts: 10
|
20 | 25 | retry_on CustomWaitTenAttemptsError, wait: ->(executions) { executions * 2 }, attempts: 10
|
21 | 26 | retry_on(CustomCatchError) { |job, error| JobBuffer.add("Dealt with a job that failed to retry in a custom way after #{job.arguments.second} attempts. Message: #{error.message}") }
|
| 27 | + |
22 | 28 | discard_on DiscardableError
|
| 29 | + discard_on FirstDiscardableErrorOfTwo, SecondDiscardableErrorOfTwo |
23 | 30 | discard_on(CustomDiscardableError) { |job, error| JobBuffer.add("Dealt with a job that was discarded in a custom way. Message: #{error.message}") }
|
24 | 31 |
|
25 | 32 | def perform(raising, attempts)
|
|
0 commit comments