# `AshWorkflow.Entities.Retry`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/ash_workflow/entities/retry.ex#L1)

Defines the failure policy for a step's or timeout's generated work.

`AshWorkflow.Scheduler.Precise` computes its own retry delay from this
struct, through `delay_ms/2`. `AshWorkflow.Scheduler.Oban` instead converts
`backoff` to the seconds ash_oban's trigger expects and hands that to
`Transformer.build_entity!(AshOban, ...)`, and lets Oban do the waiting.

# `backoff`

```elixir
@type backoff() :: AshWorkflow.Duration.t() | :exponential
```

# `t`

```elixir
@type t() :: %AshWorkflow.Entities.Retry{
  __spark_metadata__: term(),
  backoff: backoff(),
  max_attempts: pos_integer()
}
```

# `attribute_schema`

# `delay_ms`

```elixir
@spec delay_ms(t(), pos_integer()) :: non_neg_integer()
```

The delay in milliseconds before attempt number `attempt + 1`, given the
attempt number that just failed (1-based).

A fixed duration backoff is the same delay regardless of attempt.
`:exponential` uses Oban's default worker backoff formula, so
`AshWorkflow.Scheduler.Precise` and `AshWorkflow.Scheduler.Oban` agree on
timing: `trunc(:math.pow(attempt, 4) + 15) * 1000`. This has no jitter, so
the delay is deterministic and testable.

---

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