Class: GetStreamRuby::RetryConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/getstream_ruby/retry_config.rb

Overview

Opt-in auto-retry policy. Disabled by default: the client performs exactly one attempt and surfaces errors unchanged. When enabled, only GET/HEAD requests failing with HTTP 429 or a transport error are retried.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled: false, max_attempts: 3, max_backoff: 30.0) ⇒ RetryConfig

Returns a new instance of RetryConfig.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
# File 'lib/getstream_ruby/retry_config.rb', line 12

def initialize(enabled: false, max_attempts: 3, max_backoff: 30.0)
  raise ArgumentError, 'max_attempts must be >= 1' if max_attempts < 1
  raise ArgumentError, 'max_backoff must be >= 0' if max_backoff.negative?

  @enabled = enabled
  @max_attempts = max_attempts
  @max_backoff = max_backoff.to_f
end

Instance Attribute Details

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



10
11
12
# File 'lib/getstream_ruby/retry_config.rb', line 10

def max_attempts
  @max_attempts
end

#max_backoffObject (readonly)

Returns the value of attribute max_backoff.



10
11
12
# File 'lib/getstream_ruby/retry_config.rb', line 10

def max_backoff
  @max_backoff
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/getstream_ruby/retry_config.rb', line 21

def enabled?
  @enabled
end