ScheduleModule

PackageAxial

Summary

NameSignatureSynopsis
recursSchedule.recurs nCreates a schedule that recurs a fixed number of times.
spacedSchedule.spaced delayCreates a schedule that recurs with a fixed delay between attempts.
exponentialSchedule.exponential baseDelayCreates a schedule that recurs with exponential backoff.
jitteredWithSchedule.jitteredWith sample (Schedule op)Adds jitter to a schedule's delay using a caller-supplied sample source.
retrySchedule.retry schedule flowRetries a failing flow according to the supplied schedule.
repeatSchedule.repeat schedule flowRepeats a successful flow according to the supplied schedule.

recurs

Schedule.recurs n
Member
Creates a schedule that recurs a fixed number of times.

Parameters

NameTypeDescription
nintThe 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.

spaced

Schedule.spaced delay
Member
Creates a schedule that recurs with a fixed delay between attempts.

Parameters

NameTypeDescription
delayTimeSpanThe fixed time span to wait between each attempt.

Returns

Schedule<'env, 'input, int>

Verification Examples

let everySecond () = Schedule.spaced (TimeSpan.FromSeconds 1.0)

exponential

Schedule.exponential baseDelay
Member
Creates a schedule that recurs with exponential backoff.

Parameters

NameTypeDescription
baseDelayTimeSpanThe 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...

jitteredWith

Schedule.jitteredWith sample (Schedule op)
Member
Adds jitter to a schedule's delay using a caller-supplied sample source.

Parameters

NameTypeDescription
sampleunit -> floatA function returning a value in [0.0, 1.0), sampled once per attempt. Supply a deterministic function for reproducible schedules and tests.
Schedule opSchedule<'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.

retry

Schedule.retry schedule flow
Member
Retries a failing flow according to the supplied schedule.

Parameters

NameTypeDescription
scheduleSchedule<'env, 'error, 'output>The schedule that determines when and if to retry based on the error.
flowFlow<'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)

repeat

Schedule.repeat schedule flow
Member
Repeats a successful flow according to the supplied schedule.

Parameters

NameTypeDescription
scheduleSchedule<'env, 'value, 'output>The schedule that determines when and if to repeat based on the successful value.
flowFlow<'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)