sealed abstract class 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.
- Self Type
- Schedule[Env, In, Out]
- Alphabetic
- By Inheritance
- Schedule
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def &&[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, (Out, Out2)]
Returns a new schedule that performs a geometric intersection on the intervals defined by both schedules.
- def ***[Env1 <: Env, In2, Out2](that: Schedule[Env1, In2, Out2]): Schedule[Env1, (In, In2), (Out, Out2)]
Returns a new schedule that has both the inputs and outputs of this and the specified schedule.
- def *>[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Out2]
The same as
&&
, but ignores the left output. - def ++[Env1 <: Env, In1 <: In, Out2 >: Out](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Out2]
A symbolic alias for
andThen
. - def +++[Env1 <: Env, In2, Out2](that: Schedule[Env1, In2, Out2]): Schedule[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.
- def <*[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Out]
The same as
&&
, but ignores the right output. - def <*>[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, (Out, Out2)]
An operator alias for
zip
. - def <<<[Env1 <: Env, In2](that: Schedule[Env1, In2, In]): Schedule[Env1, In2, Out]
A backwards version of
>>>
. - def <||>[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Either[Out, Out2]]
Operator alias for
andThenEither
. - final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def >>>[Env1 <: Env, Out2](that: Schedule[Env1, Out, Out2]): Schedule[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.
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.
- def addDelay(f: (Out) => Duration): Schedule[Env, In, Out]
Returns a new schedule with the given delay added to every interval defined by this schedule.
- def addDelayM[Env1 <: Env](f: (Out) => URIO[Env1, Duration]): Schedule[Env1, In, Out]
Returns a new schedule with the given effectfully computed delay added to every interval defined by this schedule.
- def andThen[Env1 <: Env, In1 <: In, Out2 >: Out](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Out2]
The same as
andThenEither
, but merges the output. - def andThenEither[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Either[Out, Out2]]
Returns a new schedule that first executes this schedule to completion, and then executes the specified schedule to completion.
- def as[Out2](out2: => Out2): Schedule[Env, In, Out2]
Returns a new schedule that maps this schedule to a constant output.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def check[In1 <: In](test: (In1, Out) => Boolean): Schedule[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.
- def checkM[Env1 <: Env, In1 <: In](test: (In1, Out) => URIO[Env1, Boolean]): Schedule[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.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collectAll: Schedule[Env, In, Chunk[Out]]
Returns a new schedule that collects the outputs of this one into a chunk.
- def compose[Env1 <: Env, In2](that: Schedule[Env1, In2, In]): Schedule[Env1, In2, Out]
A named alias for
<<<
. - def contramap[Env1 <: Env, In2](f: (In2) => In): Schedule[Env, In2, Out]
Returns a new schedule that deals with a narrower class of inputs than this schedule.
- def contramapM[Env1 <: Env, In2](f: (In2) => URIO[Env1, In]): Schedule[Env1, In2, Out]
Returns a new schedule that deals with a narrower class of inputs than this schedule.
- def delayed(f: (Duration) => Duration): Schedule[Env, In, Out]
Returns a new schedule with the specified effectfully computed delay added before the start of each interval produced by this schedule.
- def delayedM[Env1 <: Env](f: (Duration) => URIO[Env1, Duration]): Schedule[Env1, In, Out]
Returns a new schedule with the specified effectfully computed delay added before the start of each interval produced by this schedule.
- def delays: Schedule[Env, In, Duration]
Returns a new schedule that outputs the delay between each occurence.
- def dimap[In2, Out2](f: (In2) => In, g: (Out) => Out2): Schedule[Env, In2, Out2]
Returns a new schedule that contramaps the input and maps the output.
- def dimapM[Env1 <: Env, In2, Out2](f: (In2) => URIO[Env1, In], g: (Out) => URIO[Env1, Out2]): Schedule[Env1, In2, Out2]
Returns a new schedule that contramaps the input and maps the output.
- def driver: UIO[Driver[Env with Clock, In, Out]]
Returns a driver that can be used to step the schedule, appropriately handling sleeping.
- def either[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, (Out, Out2)]
A named alias for
||
. - def eitherWith[Env1 <: Env, In1 <: In, Out2, Out3](that: Schedule[Env1, In1, Out2])(f: (Out, Out2) => Out3): Schedule[Env1, In1, Out3]
The same as
either
followed bymap
. - def ensuring(finalizer: UIO[Any]): Schedule[Env, In, Out]
Returns a new schedule that will run the specified finalizer as soon as the schedule is complete.
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. TheSchedule
may not initialize or the driver of the schedule may not run to completion. However, if theSchedule
ever decides not to continue, then the finalizer will be run. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def first[X]: Schedule[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.
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.
- def fold[Z](z: Z)(f: (Z, Out) => Z): Schedule[Env, In, Z]
Returns a new schedule that folds over the outputs of this one.
- def foldM[Env1 <: Env, Z](z: Z)(f: (Z, Out) => URIO[Env1, Z]): Schedule[Env1, In, Z]
Returns a new schedule that effectfully folds over the outputs of this one.
- def forever: Schedule[Env, In, Out]
Returns a new schedule that loops this one continuously, resetting the state when this schedule is done.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def intersectWith[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(f: (Interval, Interval) => Interval): Schedule[Env1, In1, (Out, Out2)]
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.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def jittered(min: Double, max: Double): Schedule[Env with Random, In, Out]
Returns a new schedule that randomly modifies the size of the intervals of this schedule.
- def jittered: Schedule[Env with Random, In, Out]
Returns a new schedule that randomly modifies the size of the intervals of this schedule.
- def left[X]: Schedule[Env, Either[In, X], Either[Out, X]]
Returns a new schedule that makes this schedule available on the
Left
side of anEither
input, allowing propagating some typeX
through this channel on demand. - def map[Out2](f: (Out) => Out2): Schedule[Env, In, Out2]
Returns a new schedule that maps the output of this schedule through the specified function.
- def mapM[Env1 <: Env, Out2](f: (Out) => URIO[Env1, Out2]): Schedule[Env1, In, Out2]
Returns a new schedule that maps the output of this schedule through the specified effectful function.
- def modifyDelay(f: (Out, Duration) => Duration): Schedule[Env, In, Out]
Returns a new schedule that modifies the delay using the specified function.
- def modifyDelayM[Env1 <: Env](f: (Out, Duration) => URIO[Env1, Duration]): Schedule[Env1, In, Out]
Returns a new schedule that modifies the delay using the specified effectual function.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def onDecision[Env1 <: Env](f: (Decision[Env, In, Out]) => URIO[Env1, Any]): Schedule[Env1, In, Out]
Returns a new schedule that applies the current one but runs the specified effect for every decision of this schedule.
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.
- def provide(env: Env): Schedule[Any, In, Out]
Returns a new schedule with its environment provided to it, so the resulting schedule does not require any environment.
- final def provideCustomLayer[Env1 <: Has[_]](layer: ZLayer[zio.ZEnv, Nothing, Env1])(implicit ev: <:<[zio.ZEnv with Env1, Env], tagged: zio.Tag[Env1]): Schedule[zio.ZEnv, In, Out]
Provides the part of the environment that is not part of the
ZEnv
, leaving a schedule that only depends on theZEnv
. - def provideLayer[Env0, Env1](layer: ZLayer[Env0, Nothing, Env1])(implicit ev1: <:<[Env1, Env], ev2: NeedsEnv[Env]): Schedule[Env0, In, Out]
Provides a layer to the schedule, which translates it to another level.
- def provideSome[Env2](f: (Env2) => Env): Schedule[Env2, In, Out]
Returns a new schedule with part of its environment provided to it, so the resulting schedule does not require any environment.
- final def provideSomeLayer[Env0 <: Has[_]]: ProvideSomeLayer[Env0, Env, In, Out]
Splits the environment into two parts, providing one part using the specified layer and leaving the remainder
Env0
. - def reconsider[Out2](f: (Decision[Env, In, Out]) => Either[Out2, (Out2, Interval)]): Schedule[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.
- def reconsiderM[Env1 <: Env, In1 <: In, Out2](f: (Decision[Env, In, Out]) => URIO[Env1, Either[Out2, (Out2, Interval)]]): Schedule[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.
- def repetitions: Schedule[Env, In, Int]
Returns a new schedule that outputs the number of repetitions of this one.
- final def resetAfter(duration: Duration): Schedule[Env, In, Out]
Return a new schedule that automatically resets the schedule to its initial state after some time of inactivity defined by
duration
. - final def resetWhen(f: (Out) => Boolean): Schedule[Env, In, Out]
Resets the schedule when the specified predicate on the schedule output evaluates to true.
- def right[X]: Schedule[Env, Either[X, In], Either[X, Out]]
Returns a new schedule that makes this schedule available on the
Right
side of anEither
input, allowing propagating some typeX
through this channel on demand. - def run(now: OffsetDateTime, input: Iterable[In]): URIO[Env, Chunk[Out]]
Runs a schedule using the provided inputs, and collects all outputs.
- def second[X]: Schedule[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.
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.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tapInput[Env1 <: Env, In1 <: In](f: (In1) => URIO[Env1, Any]): Schedule[Env1, In1, Out]
Returns a new schedule that effectfully processes every input to this schedule.
- def tapOutput[Env1 <: Env](f: (Out) => URIO[Env1, Any]): Schedule[Env1, In, Out]
Returns a new schedule that effectfully processes every output from this schedule.
- def toString(): String
- Definition Classes
- AnyRef → Any
- def unionWith[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(f: (Interval, Interval) => Interval): Schedule[Env1, In1, (Out, Out2)]
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.
- def unit: Schedule[Env, In, Unit]
Returns a new schedule that maps the output of this schedule to unit.
- def untilInput[In1 <: In](f: (In1) => Boolean): Schedule[Env, In1, Out]
Returns a new schedule that continues until the specified predicate on the input evaluates to true.
- def untilInputM[Env1 <: Env, In1 <: In](f: (In1) => URIO[Env1, Boolean]): Schedule[Env1, In1, Out]
Returns a new schedule that continues until the specified effectful predicate on the input evaluates to true.
- def untilOutput(f: (Out) => Boolean): Schedule[Env, In, Out]
Returns a new schedule that continues until the specified predicate on the output evaluates to true.
- def untilOutputM[Env1 <: Env](f: (Out) => URIO[Env1, Boolean]): Schedule[Env1, In, Out]
Returns a new schedule that continues until the specified effectful predicate on the output evaluates to true.
- def upTo(duration: Duration): Schedule[Env, In, Out]
A schedule that recurs during the given duration
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def whileInput[In1 <: In](f: (In1) => Boolean): Schedule[Env, In1, Out]
Returns a new schedule that continues for as long the specified predicate on the input evaluates to true.
- def whileInputM[Env1 <: Env, In1 <: In](f: (In1) => URIO[Env1, Boolean]): Schedule[Env1, In1, Out]
Returns a new schedule that continues for as long the specified effectful predicate on the input evaluates to true.
- def whileOutput(f: (Out) => Boolean): Schedule[Env, In, Out]
Returns a new schedule that continues for as long the specified predicate on the output evaluates to true.
- def whileOutputM[Env1 <: Env](f: (Out) => URIO[Env1, Boolean]): Schedule[Env1, In, Out]
Returns a new schedule that continues for as long the specified effectful predicate on the output evaluates to true.
- def zip[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, (Out, Out2)]
A named method for
&&
. - def zipLeft[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Out]
The same as
&&
, but ignores the right output. - def zipRight[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, Out2]
The same as
&&
, but ignores the left output. - def zipWith[Env1 <: Env, In1 <: In, Out2, Out3](that: Schedule[Env1, In1, Out2])(f: (Out, Out2) => Out3): Schedule[Env1, In1, Out3]
Equivalent to
zip
followed bymap
. - def ||[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2]): Schedule[Env1, In1, (Out, Out2)]
Returns a new schedule that performs a geometric union on the intervals defined by both schedules.
- def |||[Env1 <: Env, Out1 >: Out, In2](that: Schedule[Env1, In2, Out1]): Schedule[Env1, Either[In, In2], Out1]
Returns a new schedule that chooses between two schedules with a common output.
Deprecated Value Members
- def combineWith[Env1 <: Env, In1 <: In, Out2](that: Schedule[Env1, In1, Out2])(f: (Interval, Interval) => Interval): Schedule[Env1, In1, (Out, Out2)]
Returns a new schedule that combines this schedule with the specified schedule, merging the next intervals according to the specified merge function.
Returns a new schedule that combines this schedule with the specified schedule, merging the next intervals according to the specified merge function.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use intersectWith