Class: JetstreamBridge::PublisherRetryStrategy

Inherits:
LinearBackoffStrategy show all
Defined in:
lib/jetstream_bridge/core/retry_strategy.rb

Overview

Publisher-specific retry strategy

Constant Summary collapse

TRANSIENT_ERRORS =
begin
  errs = []
  if defined?(NATS::IO)
    errs << NATS::IO::Timeout if defined?(NATS::IO::Timeout)
    errs << NATS::IO::Error if defined?(NATS::IO::Error)
    errs << NATS::IO::NoServersError if defined?(NATS::IO::NoServersError)
    errs << NATS::IO::SocketTimeoutError if defined?(NATS::IO::SocketTimeoutError)
    errs << Errno::ECONNREFUSED
  end
  errs
end.freeze

Instance Method Summary collapse

Methods inherited from RetryStrategy

#execute

Constructor Details

#initialize(max_attempts: 2) ⇒ PublisherRetryStrategy

Returns a new instance of PublisherRetryStrategy.



128
129
130
131
132
133
134
# File 'lib/jetstream_bridge/core/retry_strategy.rb', line 128

def initialize(max_attempts: 2)
  super(
    max_attempts: max_attempts,
    delays: [0.25, 1.0],
    transient_errors: TRANSIENT_ERRORS
  )
end