WebsockexNova.Transport.Reconnection.LinearBackoff (WebsockexNova v0.1.1)
View SourceImplements a constant delay reconnection strategy.
This strategy always waits the same amount of time between reconnection attempts. It's simple and predictable but doesn't account for network congestion or other scaling concerns.
Options
:delay
- Constant delay in milliseconds (default: 1000):max_retries
- Maximum number of retry attempts (default: 5, use :infinity for unlimited)
Summary
Functions
Calculate the delay for a reconnection attempt.
Determines if a reconnection should be attempted.
Types
@type t() :: %WebsockexNova.Transport.Reconnection.LinearBackoff{ delay: non_neg_integer(), max_retries: pos_integer() | :infinity }
Functions
@spec calculate_delay(t(), pos_integer()) :: non_neg_integer()
Calculate the delay for a reconnection attempt.
For LinearBackoff, this always returns the same delay regardless of attempt number.
Parameters
strategy
- The LinearBackoff strategy struct_attempt
- The current attempt number (ignored in this strategy)
Returns
- Constant delay in milliseconds
@spec should_retry?(t(), pos_integer()) :: boolean()
Determines if a reconnection should be attempted.
Parameters
strategy
- The LinearBackoff strategy structattempt
- The current attempt number (1-based)
Returns
true
if the attempt number is within the maximum retriesfalse
otherwise