# `Tinkex.API.RetryConfig`
[🔗](https://github.com/North-Shore-AI/tinkex/blob/v0.4.0/lib/tinkex/api/retry_config.ex#L1)

Retry configuration with Python SDK parity.

Implements retry delay calculation and status code classification
matching the Python SDK's `_base_client.py`.

## Python SDK Reference

From `tinker/_constants.py`:
- `INITIAL_RETRY_DELAY = 0.5` (seconds)
- `MAX_RETRY_DELAY = 10.0` (seconds)

From `tinker/_base_client.py` `_calculate_retry_timeout`:
- Exponential backoff: `sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY)`
- Jitter: `jitter = 1 - 0.25 * random()` (range 0.75-1.0)
- Final: `timeout = sleep_seconds * jitter`

From `tinker/_base_client.py` `_should_retry`:
- Retries on status codes: 408, 409, 429, 5xx
- No wall-clock timeout; governed by `max_retries` only

# `t`

```elixir
@type t() :: %Tinkex.API.RetryConfig{
  initial_delay_ms: pos_integer(),
  max_delay_ms: pos_integer(),
  max_retries: non_neg_integer()
}
```

# `new`

```elixir
@spec new(keyword()) :: t()
```

Create a new retry config with the given options.

# `retry_delay`

```elixir
@spec retry_delay(non_neg_integer()) :: non_neg_integer()
```

Calculate retry delay for the given attempt number.

Uses Python SDK formula:
- Base delay: `initial_delay * 2^attempt`
- Capped at max_delay
- Jitter: multiplied by random value in [0.75, 1.0]

## Examples

    iex> delay = Tinkex.API.RetryConfig.retry_delay(0)
    iex> delay >= 375 and delay <= 500
    true

# `retry_delay`

```elixir
@spec retry_delay(non_neg_integer(), pos_integer(), pos_integer()) ::
  non_neg_integer()
```

Calculate retry delay with custom initial and max delays.

# `retryable_status?`

```elixir
@spec retryable_status?(integer()) :: boolean()
```

Check if a status code is retryable per Python SDK rules.

Python retries on: 408, 409, 429, 5xx

---

*Consult [api-reference.md](api-reference.md) for complete listing*
