ScheduleModule
PackageAxial
Summary
| Name | Signature | Synopsis |
|---|---|---|
| recurs | Schedule.recurs n | Creates a schedule that recurs a fixed number of times. |
| spaced | Schedule.spaced delay | Creates a schedule that recurs with a fixed delay between attempts. |
| exponential | Schedule.exponential baseDelay | Creates a schedule that recurs with exponential backoff. |
| jitteredWith | Schedule.jitteredWith sample (Schedule op) | Adds jitter to a schedule's delay using a caller-supplied sample source. |
| retry | Schedule.retry schedule flow | Retries a failing flow according to the supplied schedule. |
| repeat | Schedule.repeat schedule flow | Repeats a successful flow according to the supplied schedule. |
Creates a schedule that recurs a fixed number of times.
Parameters
| Name | Type | Description |
|---|---|---|
| n | int | The maximum number of additional times to recur, on top of the source flow's one free initial attempt. |
Returns
Schedule<'env, 'input, int>
Verification Examples
let retryThreeTimes () = Schedule.recurs 3
// Schedule.retry runs the source flow once for free, then consults the schedule at
// attempts 0, 1, 2 (three retries) before giving up: 4 executions in total.Creates a schedule that recurs with a fixed delay between attempts.
Parameters
| Name | Type | Description |
|---|---|---|
| delay | TimeSpan | The fixed time span to wait between each attempt. |
Returns
Schedule<'env, 'input, int>
Verification Examples
let everySecond () = Schedule.spaced (TimeSpan.FromSeconds 1.0)Creates a schedule that recurs with exponential backoff.
Parameters
| Name | Type | Description |
|---|---|---|
| baseDelay | TimeSpan | The initial delay for the first retry. |
Returns
Schedule<'env, 'input, TimeSpan>
Verification Examples
let backoff () = Schedule.exponential (TimeSpan.FromMilliseconds 100.0)
// Delays: 100ms, 200ms, 400ms, 800ms...Adds jitter to a schedule's delay using a caller-supplied sample source.
Parameters
| Name | Type | Description |
|---|---|---|
| sample | unit -> float | A function returning a value in [0.0, 1.0), sampled once per attempt. Supply a deterministic function for reproducible schedules and tests. |
| Schedule op | Schedule<'env, 'input, 'output> |
Returns
Schedule<'env, 'input, 'output>
Verification Examples
let schedule = Schedule.spaced (TimeSpan.FromSeconds 1.0) |> Schedule.jitteredWith (fun () -> 0.25)
// Every delay becomes 750ms.Retries a failing flow according to the supplied schedule.
Parameters
| Name | Type | Description |
|---|---|---|
| schedule | Schedule<'env, 'error, 'output> | The schedule that determines when and if to retry based on the error. |
| flow | Flow<'env, 'error, 'value> | The workflow to retry if it fails. |
Returns
Flow<'env, 'error, 'value>
Verification Examples
let flakyWork = Flow.fail "oops"
let retried = flakyWork |> Schedule.retry (Schedule.recurs 3)Repeats a successful flow according to the supplied schedule.
Parameters
| Name | Type | Description |
|---|---|---|
| schedule | Schedule<'env, 'value, 'output> | The schedule that determines when and if to repeat based on the successful value. |
| flow | Flow<'env, 'error, 'value> | The workflow to repeat if it succeeds. |
Returns
Flow<'env, 'error, 'value>
Verification Examples
let work = Flow.ok 42
let repeated = work |> Schedule.repeat (Schedule.recurs 5)
