Skip to main content
Version: 2.x

Built-in Schedules

succeed

Returns a schedule that repeats one time, producing the specified constant value:

val constant = Schedule.succeed(5)

fromFunction

A schedule that always recurs, mapping input values through the specified function:

val inc = Schedule.fromFunction[Int, Int](_ + 1)

stop

A schedule that does not recur, just stops and returns one Unit element:

val stop = Schedule.stop

once

A schedule that recurs one time an returns one Unit element:

val once = Schedule.once

forever

A schedule that always recurs and produces number of recurrence at each run:

val forever = Schedule.forever

recurs

A schedule that only recurs the specified number of times:

val recurs = Schedule.recurs(5)

spaced

A schedule that recurs continuously, each repetition spaced the specified duration from the last run:

val spaced = Schedule.spaced(10.milliseconds)

fixed

A schedule that recurs on a fixed interval. Returns the number of repetitions of the schedule so far:

val fixed = Schedule.fixed(10.seconds)

exponential

A schedule that recurs using exponential backoff:

val exponential = Schedule.exponential(10.milliseconds)

fibonacci

A schedule that always recurs, increasing delays by summing the preceding two delays (similar to the fibonacci sequence). Returns the current duration between recurrences:

val fibonacci = Schedule.fibonacci(10.milliseconds)

identity

A schedule that always decides to continue. It recurs forever, without any delay. identity schedule consumes input, and emit the same as output (Schedule[Any, A, A]):

val identity = Schedule.identity[Int]

unfold

A schedule that repeats one time from the specified state and iterator:

val unfold = Schedule.unfold(0)(_ + 1)