Schedule

zio.Schedule
See theSchedule companion object
trait Schedule[-Env, -In, +Out] extends Serializable

A Schedule[Env, In, Out] defines a recurring schedule, which consumes values of type In, and which returns values of type Out.

Schedules are defined as a possibly infinite set of intervals spread out over time. Each interval defines a window in which recurrence is possible.

When schedules are used to repeat or retry effects, the starting boundary of each interval produced by a schedule is used as the moment when the effect will be executed again.

Schedules compose in the following primary ways:

  • Union. This performs the union of the intervals of two schedules. * Intersection. This performs the intersection of the intervals of two schedules. * Sequence. This concatenates the intervals of one schedule onto another.

In addition, schedule inputs and outputs can be transformed, filtered (to terminate a schedule early in response to some input or output), and so forth.

A variety of other operators exist for transforming and combining schedules, and the companion object for Schedule contains all common types of schedules, both for performing retrying, as well as performing repetition.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Schedule[Env, In, Out]

Members list

Concise view

Type members

Types

type State

Value members

Abstract methods

def step(now: OffsetDateTime, in: In, state: State)(implicit trace: Trace): ZIO[Env, Nothing, (State, Out, Decision)]

Concrete methods

def &&[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit zippable: Zippable[Out, Out2]): WithState[(State, State), Env1, In1, Out]

Returns a new schedule that performs a geometric intersection on the intervals defined by both schedules.

Returns a new schedule that performs a geometric intersection on the intervals defined by both schedules.

Attributes

def ***[Env1 <: Env, In2, Out2](that: Schedule[Env1, In2, Out2]): WithState[(State, State), Env1, (In, In2), (Out, Out2)]

Returns a new schedule that has both the inputs and outputs of this and the specified schedule.

Returns a new schedule that has both the inputs and outputs of this and the specified schedule.

Attributes

def *>[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit trace: Trace): WithState[(State, State), Env1, In1, Out2]

The same as &&, but ignores the left output.

The same as &&, but ignores the left output.

Attributes

def ++[Env1 <: Env, In1 <: In, Out2 >: Out](that: Schedule[Env1, In1, Out2])(implicit trace: Trace): WithState[(State, State, Boolean), Env1, In1, Out2]

A symbolic alias for andThen.

A symbolic alias for andThen.

Attributes

def +++[Env1 <: Env, In2, Out2](that: Schedule[Env1, In2, Out2]): WithState[(State, State), Env1, Either[In, In2], Either[Out, Out2]]

Returns a new schedule that allows choosing between feeding inputs to this schedule, or feeding inputs to the specified schedule.

Returns a new schedule that allows choosing between feeding inputs to this schedule, or feeding inputs to the specified schedule.

Attributes

def <*[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit trace: Trace): WithState[(State, State), Env1, In1, Out]

The same as &&, but ignores the right output.

The same as &&, but ignores the right output.

Attributes

def <*>[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit zippable: Zippable[Out, Out2]): WithState[(State, State), Env1, In1, Out]

An operator alias for zip.

An operator alias for zip.

Attributes

def <<<[Env1 <: Env, In2](that: Schedule[Env1, In2, In]): WithState[(State, State), Env1, In2, Out]

A backwards version of >>>.

A backwards version of >>>.

Attributes

def <||>[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): WithState[(State, State, Boolean), Env1, In1, Either[Out, Out2]]

Operator alias for andThenEither.

Operator alias for andThenEither.

Attributes

def >>>[Env1 <: Env, Out2](that: Schedule[Env1, Out, Out2]): WithState[(State, State), Env1, In, Out2]

Returns the composition of this schedule and the specified schedule, by piping the output of this one into the input of the other. Effects described by this schedule will always be executed before the effects described by the second schedule.

Returns the composition of this schedule and the specified schedule, by piping the output of this one into the input of the other. Effects described by this schedule will always be executed before the effects described by the second schedule.

Attributes

def addDelay(f: Out => Duration)(implicit trace: Trace): WithState[State, Env, In, Out]

Returns a new schedule with the given delay added to every interval defined by this schedule.

Returns a new schedule with the given delay added to every interval defined by this schedule.

Attributes

def addDelayZIO[Env1 <: Env](f: Out => URIO[Env1, Duration])(implicit trace: Trace): WithState[State, Env1, In, Out]

Returns a new schedule with the given effectfully computed delay added to every interval defined by this schedule.

Returns a new schedule with the given effectfully computed delay added to every interval defined by this schedule.

Attributes

def andThen[Env1 <: Env, In1 <: In, Out2 >: Out](that: Schedule[Env1, In1, Out2])(implicit trace: Trace): WithState[(State, State, Boolean), Env1, In1, Out2]

The same as andThenEither, but merges the output.

The same as andThenEither, but merges the output.

Attributes

def andThenEither[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): WithState[(State, State, Boolean), Env1, In1, Either[Out, Out2]]

Returns a new schedule that first executes this schedule to completion, and then executes the specified schedule to completion.

Returns a new schedule that first executes this schedule to completion, and then executes the specified schedule to completion.

Attributes

def as[Out2](out2: => Out2)(implicit trace: Trace): WithState[State, Env, In, Out2]

Returns a new schedule that maps this schedule to a constant output.

Returns a new schedule that maps this schedule to a constant output.

Attributes

def check[In1 <: In](test: (In1, Out) => Boolean)(implicit trace: Trace): WithState[State, Env, In1, Out]

Returns a new schedule that passes each input and output of this schedule to the specified function, and then determines whether or not to continue based on the return value of the function.

Returns a new schedule that passes each input and output of this schedule to the specified function, and then determines whether or not to continue based on the return value of the function.

Attributes

def checkZIO[Env1 <: Env, In1 <: In](test: (In1, Out) => URIO[Env1, Boolean]): WithState[State, Env1, In1, Out]

Returns a new schedule that passes each input and output of this schedule to the specified function, and then determines whether or not to continue based on the return value of the function.

Returns a new schedule that passes each input and output of this schedule to the specified function, and then determines whether or not to continue based on the return value of the function.

Attributes

def collectAll[Out1 >: Out](implicit trace: Trace): WithState[(State, Chunk[Out1]), Env, In, Chunk[Out1]]

Returns a new schedule that collects the outputs of this one into a chunk.

Returns a new schedule that collects the outputs of this one into a chunk.

Attributes

def collectUntil[Out1 >: Out](f: Out => Boolean)(implicit trace: Trace): WithState[(State, Chunk[Out1]), Env, In, Chunk[Out1]]

Returns a new schedule that collects the outputs of this one into a list until the condition f fails.

Returns a new schedule that collects the outputs of this one into a list until the condition f fails.

Attributes

def collectUntilZIO[Env1 <: Env, Out1 >: Out](f: Out => URIO[Env1, Boolean])(implicit trace: Trace): WithState[(State, Chunk[Out1]), Env1, In, Chunk[Out1]]

Returns a new schedule that collects the outputs of this one into a list until the effectual condition f fails.

Returns a new schedule that collects the outputs of this one into a list until the effectual condition f fails.

Attributes

def collectWhile[Out1 >: Out](f: Out => Boolean)(implicit trace: Trace): WithState[(State, Chunk[Out1]), Env, In, Chunk[Out1]]

Returns a new schedule that collects the outputs of this one into a list as long as the condition f holds.

Returns a new schedule that collects the outputs of this one into a list as long as the condition f holds.

Attributes

def collectWhileZIO[Env1 <: Env, Out1 >: Out](f: Out => URIO[Env1, Boolean])(implicit trace: Trace): WithState[(State, Chunk[Out1]), Env1, In, Chunk[Out1]]

Returns a new schedule that collects the outputs of this one into a list as long as the effectual condition f holds.

Returns a new schedule that collects the outputs of this one into a list as long as the effectual condition f holds.

Attributes

def compose[Env1 <: Env, In2](that: Schedule[Env1, In2, In]): WithState[(State, State), Env1, In2, Out]

A named alias for <<<.

A named alias for <<<.

Attributes

def contramap[Env1 <: Env, In2](f: In2 => In)(implicit trace: Trace): WithState[State, Env, In2, Out]

Returns a new schedule that deals with a narrower class of inputs than this schedule.

Returns a new schedule that deals with a narrower class of inputs than this schedule.

Attributes

def contramapZIO[Env1 <: Env, In2](f: In2 => URIO[Env1, In]): WithState[State, Env1, In2, Out]

Returns a new schedule that deals with a narrower class of inputs than this schedule.

Returns a new schedule that deals with a narrower class of inputs than this schedule.

Attributes

def delayed(f: Duration => Duration)(implicit trace: Trace): WithState[State, Env, In, Out]

Returns a new schedule with the specified effectfully computed delay added before the start of each interval produced by this schedule.

Returns a new schedule with the specified effectfully computed delay added before the start of each interval produced by this schedule.

Attributes

def delayedZIO[Env1 <: Env](f: Duration => URIO[Env1, Duration]): WithState[State, Env1, In, Out]

Returns a new schedule with the specified effectfully computed delay added before the start of each interval produced by this schedule.

Returns a new schedule with the specified effectfully computed delay added before the start of each interval produced by this schedule.

Attributes

def delays: WithState[State, Env, In, Duration]

Returns a new schedule that outputs the delay between each occurence.

Returns a new schedule that outputs the delay between each occurence.

Attributes

def dimap[In2, Out2](f: In2 => In, g: Out => Out2)(implicit trace: Trace): WithState[State, Env, In2, Out2]

Returns a new schedule that contramaps the input and maps the output.

Returns a new schedule that contramaps the input and maps the output.

Attributes

def dimapZIO[Env1 <: Env, In2, Out2](f: In2 => URIO[Env1, In], g: Out => URIO[Env1, Out2]): WithState[State, Env1, In2, Out2]

Returns a new schedule that contramaps the input and maps the output.

Returns a new schedule that contramaps the input and maps the output.

Attributes

def driver(implicit trace: Trace): UIO[Driver[State, Env, In, Out]]

Returns a driver that can be used to step the schedule, appropriately handling sleeping.

Returns a driver that can be used to step the schedule, appropriately handling sleeping.

Attributes

def either[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): WithState[(State, State), Env1, In1, (Out, Out2)]

A named alias for ||.

A named alias for ||.

Attributes

def eitherWith[Env1 <: Env, In1 <: In, Out2, Out3](that: Schedule[Env1, In1, Out2])(f: (Out, Out2) => Out3)(implicit trace: Trace): WithState[(State, State), Env1, In1, Out3]

The same as either followed by map.

The same as either followed by map.

Attributes

def ensuring(finalizer: UIO[Any]): WithState[State, Env, In, Out]

Returns a new schedule that will run the specified finalizer as soon as the schedule is complete. Note that unlike ZIO#ensuring, this method does not guarantee the finalizer will be run. The Schedule may not initialize or the driver of the schedule may not run to completion. However, if the Schedule ever decides not to continue, then the finalizer will be run.

Returns a new schedule that will run the specified finalizer as soon as the schedule is complete. Note that unlike ZIO#ensuring, this method does not guarantee the finalizer will be run. The Schedule may not initialize or the driver of the schedule may not run to completion. However, if the Schedule ever decides not to continue, then the finalizer will be run.

Attributes

def first[X]: WithState[(State, Unit), Env, (In, X), (Out, X)]

Returns a new schedule that packs the input and output of this schedule into the first element of a tuple. This allows carrying information through this schedule.

Returns a new schedule that packs the input and output of this schedule into the first element of a tuple. This allows carrying information through this schedule.

Attributes

def fold[Z](z: Z)(f: (Z, Out) => Z)(implicit trace: Trace): WithState[(State, Z), Env, In, Z]

Returns a new schedule that folds over the outputs of this one.

Returns a new schedule that folds over the outputs of this one.

Attributes

def foldZIO[Env1 <: Env, Z](z: Z)(f: (Z, Out) => URIO[Env1, Z]): WithState[(State, Z), Env1, In, Z]

Returns a new schedule that effectfully folds over the outputs of this one.

Returns a new schedule that effectfully folds over the outputs of this one.

Attributes

def forever: WithState[State, Env, In, Out]

Returns a new schedule that loops this one continuously, resetting the state when this schedule is done.

Returns a new schedule that loops this one continuously, resetting the state when this schedule is done.

Attributes

def intersectWith[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(f: (Intervals, Intervals) => Intervals)(implicit zippable: Zippable[Out, Out2]): WithState[(State, State), Env1, In1, Out]

Returns a new schedule that combines this schedule with the specified schedule, continuing as long as both schedules want to continue and merging the next intervals according to the specified merge function.

Returns a new schedule that combines this schedule with the specified schedule, continuing as long as both schedules want to continue and merging the next intervals according to the specified merge function.

Attributes

def jittered(implicit trace: Trace): WithState[State, Env, In, Out]

Returns a new schedule that randomly modifies the size of the intervals of this schedule.

Returns a new schedule that randomly modifies the size of the intervals of this schedule.

Attributes

def jittered(min: Double, max: Double)(implicit trace: Trace): WithState[State, Env, In, Out]

Returns a new schedule that randomly modifies the size of the intervals of this schedule.

Returns a new schedule that randomly modifies the size of the intervals of this schedule.

The new interval size is between min * old interval size and max * old interval size.

Research shows that jittered(0.0, 1.0) is a suitable range for a retrying schedule.

Attributes

def left[X]: WithState[(State, Unit), Env, Either[In, X], Either[Out, X]]

Returns a new schedule that makes this schedule available on the Left side of an Either input, allowing propagating some type X through this channel on demand.

Returns a new schedule that makes this schedule available on the Left side of an Either input, allowing propagating some type X through this channel on demand.

Attributes

def map[Out2](f: Out => Out2)(implicit trace: Trace): WithState[State, Env, In, Out2]

Returns a new schedule that maps the output of this schedule through the specified function.

Returns a new schedule that maps the output of this schedule through the specified function.

Attributes

def mapZIO[Env1 <: Env, Out2](f: Out => URIO[Env1, Out2]): WithState[State, Env1, In, Out2]

Returns a new schedule that maps the output of this schedule through the specified effectful function.

Returns a new schedule that maps the output of this schedule through the specified effectful function.

Attributes

def modifyDelay(f: (Out, Duration) => Duration): WithState[State, Env, In, Out]

Returns a new schedule that modifies the delay using the specified function.

Returns a new schedule that modifies the delay using the specified function.

Attributes

def modifyDelayZIO[Env1 <: Env](f: (Out, Duration) => URIO[Env1, Duration]): WithState[State, Env1, In, Out]

Returns a new schedule that modifies the delay using the specified effectual function.

Returns a new schedule that modifies the delay using the specified effectual function.

Attributes

def onDecision[Env1 <: Env](f: (State, Out, Decision) => URIO[Env1, Any]): WithState[State, Env1, In, Out]

Returns a new schedule that applies the current one but runs the specified effect for every decision of this schedule. This can be used to create schedules that log failures, decisions, or computed values.

Returns a new schedule that applies the current one but runs the specified effect for every decision of this schedule. This can be used to create schedules that log failures, decisions, or computed values.

Attributes

def passthrough[In1 <: In](implicit trace: Trace): WithState[State, Env, In1, In1]

Returns a new schedule that passes through the inputs of this schedule.

Returns a new schedule that passes through the inputs of this schedule.

Attributes

def provideEnvironment(env: ZEnvironment[Env]): WithState[State, Any, In, Out]

Returns a new schedule with its environment provided to it, so the resulting schedule does not require any environment.

Returns a new schedule with its environment provided to it, so the resulting schedule does not require any environment.

Attributes

def provideSomeEnvironment[Env2](f: ZEnvironment[Env2] => ZEnvironment[Env]): WithState[State, Env2, In, Out]

Transforms the environment being provided to this schedule with the specified function.

Transforms the environment being provided to this schedule with the specified function.

Attributes

def reconsider[Out2](f: (State, Out, Decision) => Either[Out2, (Out2, Interval)])(implicit trace: Trace): WithState[State, Env, In, Out2]

Returns a new schedule that reconsiders every decision made by this schedule, possibly modifying the next interval and the output type in the process.

Returns a new schedule that reconsiders every decision made by this schedule, possibly modifying the next interval and the output type in the process.

Attributes

def reconsiderZIO[Env1 <: Env, In1 <: In, Out2](f: (State, Out, Decision) => URIO[Env1, Either[Out2, (Out2, Interval)]]): WithState[State, Env1, In1, Out2]

Returns a new schedule that effectfully reconsiders every decision made by this schedule, possibly modifying the next interval and the output type in the process.

Returns a new schedule that effectfully reconsiders every decision made by this schedule, possibly modifying the next interval and the output type in the process.

Attributes

def repetitions(implicit trace: Trace): WithState[(State, Long), Env, In, Long]

Returns a new schedule that outputs the number of repetitions of this one.

Returns a new schedule that outputs the number of repetitions of this one.

Attributes

final def resetAfter(duration: Duration)(implicit trace: Trace): WithState[(State, Option[OffsetDateTime]), Env, In, Out]

Return a new schedule that automatically resets the schedule to its initial state after some time of inactivity defined by duration.

Return a new schedule that automatically resets the schedule to its initial state after some time of inactivity defined by duration.

Attributes

final def resetWhen(f: Out => Boolean): WithState[State, Env, In, Out]

Resets the schedule when the specified predicate on the schedule output evaluates to true.

Resets the schedule when the specified predicate on the schedule output evaluates to true.

Attributes

def right[X]: WithState[(Unit, State), Env, Either[X, In], Either[X, Out]]

Returns a new schedule that makes this schedule available on the Right side of an Either input, allowing propagating some type X through this channel on demand.

Returns a new schedule that makes this schedule available on the Right side of an Either input, allowing propagating some type X through this channel on demand.

Attributes

def run(now: OffsetDateTime, input: Iterable[In])(implicit trace: Trace): URIO[Env, Chunk[Out]]

Runs a schedule using the provided inputs, and collects all outputs.

Runs a schedule using the provided inputs, and collects all outputs.

Attributes

def second[X]: WithState[(Unit, State), Env, (X, In), (X, Out)]

Returns a new schedule that packs the input and output of this schedule into the second element of a tuple. This allows carrying information through this schedule.

Returns a new schedule that packs the input and output of this schedule into the second element of a tuple. This allows carrying information through this schedule.

Attributes

def tapInput[Env1 <: Env, In1 <: In](f: In1 => URIO[Env1, Any]): WithState[State, Env1, In1, Out]

Returns a new schedule that effectfully processes every input to this schedule.

Returns a new schedule that effectfully processes every input to this schedule.

Attributes

def tapOutput[Env1 <: Env](f: Out => URIO[Env1, Any]): WithState[State, Env1, In, Out]

Returns a new schedule that effectfully processes every output from this schedule.

Returns a new schedule that effectfully processes every output from this schedule.

Attributes

def unionWith[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(f: (Intervals, Intervals) => Intervals)(implicit zippable: Zippable[Out, Out2]): WithState[(State, State), Env1, In1, Out]

Returns a new schedule that combines this schedule with the specified schedule, continuing as long as either schedule wants to continue and merging the next intervals according to the specified merge function.

Returns a new schedule that combines this schedule with the specified schedule, continuing as long as either schedule wants to continue and merging the next intervals according to the specified merge function.

Attributes

def unit(implicit trace: Trace): WithState[State, Env, In, Unit]

Returns a new schedule that maps the output of this schedule to unit.

Returns a new schedule that maps the output of this schedule to unit.

Attributes

def untilInput[In1 <: In](f: In1 => Boolean)(implicit trace: Trace): WithState[State, Env, In1, Out]

Returns a new schedule that continues until the specified predicate on the input evaluates to true.

Returns a new schedule that continues until the specified predicate on the input evaluates to true.

Attributes

def untilInputZIO[Env1 <: Env, In1 <: In](f: In1 => URIO[Env1, Boolean])(implicit trace: Trace): WithState[State, Env1, In1, Out]

Returns a new schedule that continues until the specified effectful predicate on the input evaluates to true.

Returns a new schedule that continues until the specified effectful predicate on the input evaluates to true.

Attributes

def untilOutput(f: Out => Boolean)(implicit trace: Trace): WithState[State, Env, In, Out]

Returns a new schedule that continues until the specified predicate on the output evaluates to true.

Returns a new schedule that continues until the specified predicate on the output evaluates to true.

Attributes

def untilOutputZIO[Env1 <: Env](f: Out => URIO[Env1, Boolean])(implicit trace: Trace): WithState[State, Env1, In, Out]

Returns a new schedule that continues until the specified effectful predicate on the output evaluates to true.

Returns a new schedule that continues until the specified effectful predicate on the output evaluates to true.

Attributes

def upTo(duration: Duration)(implicit trace: Trace): WithState[(State, Option[OffsetDateTime]), Env, In, Out]

A schedule that recurs during the given duration

A schedule that recurs during the given duration

Attributes

def whileInput[In1 <: In](f: In1 => Boolean)(implicit trace: Trace): WithState[State, Env, In1, Out]

Returns a new schedule that continues for as long the specified predicate on the input evaluates to true.

Returns a new schedule that continues for as long the specified predicate on the input evaluates to true.

Attributes

def whileInputZIO[Env1 <: Env, In1 <: In](f: In1 => URIO[Env1, Boolean]): WithState[State, Env1, In1, Out]

Returns a new schedule that continues for as long the specified effectful predicate on the input evaluates to true.

Returns a new schedule that continues for as long the specified effectful predicate on the input evaluates to true.

Attributes

def whileOutput(f: Out => Boolean)(implicit trace: Trace): WithState[State, Env, In, Out]

Returns a new schedule that continues for as long the specified predicate on the output evaluates to true.

Returns a new schedule that continues for as long the specified predicate on the output evaluates to true.

Attributes

def whileOutputZIO[Env1 <: Env](f: Out => URIO[Env1, Boolean]): WithState[State, Env1, In, Out]

Returns a new schedule that continues for as long the specified effectful predicate on the output evaluates to true.

Returns a new schedule that continues for as long the specified effectful predicate on the output evaluates to true.

Attributes

def zip[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit zippable: Zippable[Out, Out2]): WithState[(State, State), Env1, In1, Out]

A named method for &&.

A named method for &&.

Attributes

def zipLeft[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit trace: Trace): WithState[(State, State), Env1, In1, Out]

The same as &&, but ignores the right output.

The same as &&, but ignores the right output.

Attributes

def zipRight[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit trace: Trace): WithState[(State, State), Env1, In1, Out2]

The same as &&, but ignores the left output.

The same as &&, but ignores the left output.

Attributes

def zipWith[Env1 <: Env, In1 <: In, Out2, Out3](that: Schedule[Env1, In1, Out2])(f: (Out, Out2) => Out3)(implicit trace: Trace): WithState[(State, State), Env1, In1, Out3]

Equivalent to zip followed by map.

Equivalent to zip followed by map.

Attributes

def ||[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(implicit zippable: Zippable[Out, Out2]): WithState[(State, State), Env1, In1, Out]

Returns a new schedule that performs a geometric union on the intervals defined by both schedules.

Returns a new schedule that performs a geometric union on the intervals defined by both schedules.

Attributes

def |||[Env1 <: Env, Out1 >: Out, In2](that: Schedule[Env1, In2, Out1])(implicit trace: Trace): WithState[(State, State), Env1, Either[In, In2], Out1]

Returns a new schedule that chooses between two schedules with a common output.

Returns a new schedule that chooses between two schedules with a common output.

Attributes