Class: TxghQueue::Backends::Sqs::RetryLogic

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(message_attributes, current_status)
  @message_attributes = message_attributes.dup
  @current_status = current_status
end

Instance Attribute Details

#current_statusObject (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_attributesObject (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
  @message_attributes
end

Instance Method Details

#next_delay_secondsObject



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

Returns:

  • (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

Returns:

  • (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_paramsObject



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