Class: TxghQueue::Backends::Sqs::RetryLogic
- Inherits:
-
Object
- Object
- TxghQueue::Backends::Sqs::RetryLogic
- Defined in:
- lib/txgh-queue/backends/sqs/retry_logic.rb
Constant Summary collapse
- SEQUENTIAL_MAX_RETRIES =
5
- OVERALL_MAX_RETRIES =
15
- DELAY_INTERVALS =
SQS max is 15 minutes, or 900 seconds
[16, 32, 64, 128, 256, 512, 900]
Instance Attribute Summary collapse
-
#current_status ⇒ Object
readonly
Returns the value of attribute current_status.
-
#message_attributes ⇒ Object
readonly
Returns the value of attribute message_attributes.
Instance Method Summary collapse
-
#initialize(message_attributes, current_status) ⇒ RetryLogic
constructor
A new instance of RetryLogic.
- #next_delay_seconds ⇒ Object
- #retries_exceeded? ⇒ Boolean
- #retry? ⇒ Boolean
- #sqs_retry_params ⇒ Object
Constructor Details
#initialize(message_attributes, current_status) ⇒ RetryLogic
Returns a new instance of RetryLogic.
17 18 19 20 |
# File 'lib/txgh-queue/backends/sqs/retry_logic.rb', line 17 def initialize(, current_status) @message_attributes = .dup @current_status = current_status end |
Instance Attribute Details
#current_status ⇒ Object (readonly)
Returns the value of attribute current_status.
15 16 17 |
# File 'lib/txgh-queue/backends/sqs/retry_logic.rb', line 15 def current_status @current_status end |
#message_attributes ⇒ Object (readonly)
Returns the value of attribute message_attributes.
15 16 17 |
# File 'lib/txgh-queue/backends/sqs/retry_logic.rb', line 15 def @message_attributes end |
Instance Method Details
#next_delay_seconds ⇒ Object
32 33 34 35 36 |
# File 'lib/txgh-queue/backends/sqs/retry_logic.rb', line 32 def next_delay_seconds raise RetriesExceededError unless retry? return 0 unless retry_with_delay? DELAY_INTERVALS[[current_sequence.size - 1, 0].max] end |
#retries_exceeded? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/txgh-queue/backends/sqs/retry_logic.rb', line 26 def retries_exceeded? max_overall_retries_exceeded? || max_sequential_retries_exceeded? || max_sequential_delays_exceeded? end |
#retry? ⇒ Boolean
22 23 24 |
# File 'lib/txgh-queue/backends/sqs/retry_logic.rb', line 22 def retry? retry_with_delay? || retry_without_delay? end |
#sqs_retry_params ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/txgh-queue/backends/sqs/retry_logic.rb', line 38 def sqs_retry_params if retry_without_delay? sqs_params_without_delay elsif retry_with_delay? sqs_params_with_delay else raise RetriesExceededError end end |