Class: EventQ::Amazon::CalculateVisibilityTimeout
- Inherits:
-
Object
- Object
- EventQ::Amazon::CalculateVisibilityTimeout
- Defined in:
- lib/eventq/eventq_aws/aws_calculate_visibility_timeout.rb
Overview
Class responsible to know how to calculate message Visibility Timeout for Amazon SQS
Instance Method Summary collapse
-
#call(retry_attempts:, queue_settings:) ⇒ Integer
Calculate Visibility Timeout.
-
#initialize(max_timeout:, logger: EventQ.logger) ⇒ CalculateVisibilityTimeout
constructor
A new instance of CalculateVisibilityTimeout.
Constructor Details
#initialize(max_timeout:, logger: EventQ.logger) ⇒ CalculateVisibilityTimeout
Returns a new instance of CalculateVisibilityTimeout.
7 8 9 10 |
# File 'lib/eventq/eventq_aws/aws_calculate_visibility_timeout.rb', line 7 def initialize(max_timeout:, logger: EventQ.logger) @max_timeout = seconds_to_ms(max_timeout) @logger = logger end |
Instance Method Details
#call(retry_attempts:, queue_settings:) ⇒ Integer
Calculate Visibility Timeout
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/eventq/eventq_aws/aws_calculate_visibility_timeout.rb', line 24 def call(retry_attempts:, queue_settings:) @retry_attempts = retry_attempts @allow_retry_back_off = queue_settings.fetch(:allow_retry_back_off) @allow_exponential_back_off = queue_settings.fetch(:allow_exponential_back_off) @max_retry_delay = queue_settings.fetch(:max_retry_delay) @retry_back_off_grace = queue_settings.fetch(:retry_back_off_grace) @retry_back_off_weight = queue_settings.fetch(:retry_back_off_weight) @retry_jitter_ratio = queue_settings.fetch(:retry_jitter_ratio) @retry_delay = queue_settings.fetch(:retry_delay) visibility_timeout = if @allow_retry_back_off && retry_past_grace_period? timeout_with_back_off else timeout_without_back_off end visibility_timeout = apply_jitter(visibility_timeout) if @retry_jitter_ratio > 0 ms_to_seconds(visibility_timeout) end |