coinglecko/retry
Transport-agnostic retry utility for API calls.
Types
Configuration for retry behavior.
pub type RetryConfig {
RetryConfig(
max_attempts: Int,
should_retry: fn(error.CoinGeckoError) -> Bool,
)
}
Constructors
-
RetryConfig( max_attempts: Int, should_retry: fn(error.CoinGeckoError) -> Bool, )
Error returned when all retry attempts are exhausted.
pub type RetryError {
RetryExhausted(last_error: error.CoinGeckoError, attempts: Int)
}
Constructors
-
RetryExhausted(last_error: error.CoinGeckoError, attempts: Int)
Values
pub fn default_config() -> RetryConfig
Create a default retry configuration with 3 attempts.
pub fn execute(
request req: request.Request(String),
decoder decoder: decode.Decoder(a),
send sender: fn(request.Request(String)) -> Result(
response.Response(String),
String,
),
config config: RetryConfig,
) -> Result(a, RetryError)
Execute a request with retry logic.
pub fn with_max_attempts(
config: RetryConfig,
max max: Int,
) -> RetryConfig
Override the maximum number of attempts.