trait Schedule[-R, -A, +B] extends Serializable
Defines a stateful, possibly effectful, recurring schedule of actions.
A Schedule[R, A, B]
consumes A
values, and based on the inputs and the
internal state, decides whether to continue or halt. Every decision is
accompanied by a (possibly zero) delay, and an output value of type B
.
Schedules compose in each of the following ways:
1. Intersection, using the &&
operator, which requires that both schedules
continue, using the longer of the two durations.
2. Union, using the ||
operator, which requires that only one schedule
continues, using the shorter of the two durations.
3. Sequence, using the <||>
operator, which runs the first schedule until
it ends, and then switches over to the second schedule.
Schedule[R, A, B]
forms a profunctor on [A, B]
, an applicative functor on
B
, and a monoid, allowing rich composition of different schedules.
- Self Type
- Schedule[R, A, B]
- Alphabetic
- By Inheritance
- Schedule
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
abstract
type
State
The internal state type of the schedule.
Abstract Value Members
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
&&[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, (B, C)]
Returns a new schedule that continues only as long as both schedules continue, using the maximum of the delays of the two schedules.
-
final
def
***[R1 <: R, C, D](that: Schedule[R1, C, D]): Schedule[R1, (A, C), (B, D)]
Split the input
-
final
def
*>[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, C]
The same as
&&
, but ignores the left output. -
final
def
++[R1 <: R, A1 <: A, B1 >: B](that: Schedule[R1, A1, B1]): Schedule[R1, A1, B1]
A symbolic alias for
andThen
. -
final
def
+++[R1 <: R, C, D](that: Schedule[R1, C, D]): Schedule[R1, Either[A, C], Either[B, D]]
Chooses between two schedules with different outputs.
-
final
def
<*[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, B]
The same as
&&
, but ignores the right output. -
final
def
<*>[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, (B, C)]
Returns a new schedule that continues only as long as both schedules continue, using the maximum of the delays of the two schedules.
-
final
def
<<<[R1 <: R, C](that: Schedule[R1, C, A]): Schedule[R1, C, B]
A backwards version of
>>>
. -
final
def
<||>[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, Either[B, C]]
Operator alias for
andThenEither
. -
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
>>>[R1 <: R, C](that: Schedule[R1, B, C]): Schedule[R1, A, C]
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.
-
final
def
addDelay(f: (B) ⇒ Duration): Schedule[R with Clock, A, B]
Returns a new schedule with the given delay added to every update.
-
final
def
addDelayM[R1 <: R](f: (B) ⇒ ZIO[R1, Nothing, Duration]): Schedule[R1 with Clock, A, B]
Returns a new schedule with the effectfully calculated delay added to every update.
-
final
def
andThen[R1 <: R, A1 <: A, B1 >: B](that: Schedule[R1, A1, B1]): Schedule[R1, A1, B1]
The same as
andThenEither
, but merges the output. -
final
def
andThenEither[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, Either[B, C]]
Returns a new schedule that first executes this schedule to completion, and then executes the specified schedule to completion.
-
final
def
as[C](c: ⇒ C): Schedule[R, A, C]
Returns a new schedule that maps this schedule to a constant output.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
final
def
both[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, (B, C)]
A named alias for
&&
. -
final
def
bothWith[R1 <: R, A1 <: A, C, D](that: Schedule[R1, A1, C])(f: (B, C) ⇒ D): Schedule[R1, A1, D]
The same as
both
followed bymap
. -
final
def
check[A1 <: A](test: (A1, B) ⇒ UIO[Boolean]): Schedule[R, A1, B]
Peeks at the output produced by this schedule, executes some action, and then continues the schedule or not based on the specified state predicate.
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
collectAll: Schedule[R, A, List[B]]
Returns a new schedule that collects the outputs of this one into a list.
-
final
def
compose[R1 <: R, C](that: Schedule[R1, C, A]): Schedule[R1, C, B]
An alias for
<<<
-
final
def
contramap[A1](f: (A1) ⇒ A): Schedule[R, A1, B]
Returns a new schedule that deals with a narrower class of inputs than this schedule.
-
final
def
delayed[R1 <: R](f: (Duration) ⇒ Duration)(implicit ev1: IsHas[R1], ev2: <:<[R1, Clock]): Schedule[R1, A, B]
Returns a new schedule with the specified pure modification applied to each delay produced by this schedule.
-
final
def
delayedM[R1 <: R](f: (Duration) ⇒ ZIO[R1, Nothing, Duration])(implicit ev1: IsHas[R1], ev2: <:<[R1, Clock]): Schedule[R1, A, B]
Returns a new schedule with the specified effectful modification applied to each delay produced by this schedule.
-
final
def
dimap[A1, C](f: (A1) ⇒ A, g: (B) ⇒ C): Schedule[R, A1, C]
Returns a new schedule that contramaps the input and maps the output.
-
final
def
either[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, (B, C)]
A named alias for
||
. -
final
def
eitherWith[R1 <: R, A1 <: A, C, D](that: Schedule[R1, A1, C])(f: (B, C) ⇒ D): Schedule[R1, A1, D]
The same as
either
followed bymap
. -
final
def
ensuring(finalizer: UIO[_]): Schedule[R, A, B]
Runs the specified finalizer as soon as the schedule is complete.
Runs 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: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
first[R1 <: R, C]: Schedule[R1, (A, C), (B, C)]
Puts this schedule into the first element of a tuple, and passes along another value unchanged as the second element of the tuple.
-
final
def
fold[Z](z: Z)(f: (Z, B) ⇒ Z): Schedule[R, A, Z]
Returns a new schedule that folds over the outputs of this one.
-
final
def
foldM[R1 <: R, Z](z: Z)(f: (Z, B) ⇒ ZIO[R1, Nothing, Z]): Schedule[R1, A, Z]
Returns a new schedule that effectfully folds over the outputs of this one.
-
final
def
forever: Schedule[R, A, B]
Returns a new schedule that loops this one forever, resetting the state when this schedule is done.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
initialized[R1 <: R, A1 <: A](f: (ZIO[R1, Nothing, State]) ⇒ ZIO[R1, Nothing, State]): Schedule[R1, A1, B]
Returns a new schedule with the specified initial state transformed by the specified initial transformer.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
jittered[R1 <: R](min: Double, max: Double)(implicit ev1: IsHas[R1], ev2: <:<[R1, Clock]): Schedule[R1 with Random, A, B]
Applies random jitter to all sleeps executed by the schedule.
- def jittered[R1 <: R](implicit ev1: IsHas[R1], ev2: <:<[R1, Clock]): Schedule[R1 with Random, A, B]
-
final
def
left[C]: Schedule[R, Either[A, C], Either[B, C]]
Puts this schedule into the first element of a either, and passes along another value unchanged as the second element of the either.
-
final
def
map[A1 <: A, C](f: (B) ⇒ C): Schedule[R, A1, C]
Returns a new schedule that maps over the output of this one.
-
final
def
modifyDelay[R1 <: R](f: (B, Duration) ⇒ ZIO[R1, Nothing, Duration])(implicit ev1: IsHas[R1], ev2: <:<[R1, Clock]): Schedule[R1, A, B]
Returns a new schedule with the specified effectful modification applied to each sleep performed by this schedule.
Returns a new schedule with the specified effectful modification applied to each sleep performed by this schedule.
Note that this does not apply to sleeps performed in Schedule#initial. All effects executed while calculating the modified duration will run with the old environment.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
noDelay[R1 <: R](implicit ev1: IsHas[R1], ev2: <:<[R1, Clock]): Schedule[R1, A, B]
Returns a new schedule that will not perform any sleep calls between recurrences.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
onDecision[A1 <: A, R1 <: R](f: (A1, Option[State]) ⇒ URIO[R1, Any]): Schedule[R1, A1, B]
A new schedule that applies the current one but runs the specified effect for every decision of this schedule.
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.
-
final
def
provide(r: R)(implicit ev: NeedsEnv[R]): Schedule[Any, A, B]
Provide all requirements to the schedule.
-
final
def
provideSome[R1](f: (R1) ⇒ R)(implicit ev: NeedsEnv[R]): Schedule[R1, A, B]
Provide some of the requirements to the schedule.
-
final
def
reconsider[R1 <: R, A1 <: A](f: (A1, Either[State, State]) ⇒ ZIO[R1, Unit, State]): Schedule[R1, A1, B]
Returns a new schedule that effectfully reconsiders the decision made by this schedule.
Returns a new schedule that effectfully reconsiders the decision made by this schedule. The provided either will be a Left if the schedule has failed and will contain the old state or a Right with the new state if the schedule has updated successfully.
-
final
def
repetitions: Schedule[R, A, Int]
Emit the number of repetitions of the schedule so far.
-
final
def
right[C]: Schedule[R, Either[C, A], Either[C, B]]
Puts this schedule into the second element of a either, and passes along another value unchanged as the first element of the either.
-
final
def
run(input: Iterable[A]): ZIO[R, Nothing, List[B]]
Run a schedule using the provided input and collect all outputs.
-
final
def
second[C]: Schedule[R, (C, A), (C, B)]
Puts this schedule into the second element of a tuple, and passes along another value unchanged as the first element of the tuple.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
tapInput[R1 <: R, A1 <: A](f: (A1) ⇒ ZIO[R1, Nothing, Unit]): Schedule[R1, A1, B]
Sends every input value to the specified sink.
-
final
def
tapOutput[R1 <: R](f: (B) ⇒ ZIO[R1, Nothing, Unit]): Schedule[R1, A, B]
Sends every output value to the specified sink.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
unit: Schedule[R, A, Unit]
Returns a new schedule that maps this schedule to a Unit output.
-
final
def
untilInput[A1 <: A](f: (A1) ⇒ Boolean): Schedule[R, A1, B]
Returns a new schedule that continues the schedule only until the predicate is satisfied on the input of the schedule.
-
final
def
untilInputM[A1 <: A](f: (A1) ⇒ UIO[Boolean]): Schedule[R, A1, B]
Returns a new schedule that continues the schedule only until the effectful predicate is satisfied on the input of the schedule.
-
final
def
untilOutput(f: (B) ⇒ Boolean): Schedule[R, A, B]
Returns a new schedule that continues the schedule only until the predicate is satisfied on the output value of the schedule.
-
final
def
untilOutputM(f: (B) ⇒ UIO[Boolean]): Schedule[R, A, B]
Returns a new schedule that continues the schedule only until the predicate is satisfied on the output value of the schedule.
-
final
def
updated[R1 <: R, A1 <: A](f: ((A, State) ⇒ ZIO[R, Unit, State]) ⇒ (A1, State) ⇒ ZIO[R1, Unit, State]): Schedule[R1, A1, B]
Returns a new schedule with the update function transformed by the specified update transformer.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
whileInput[A1 <: A](f: (A1) ⇒ Boolean): Schedule[R, A1, B]
Returns a new schedule that continues this schedule so long as the predicate is satisfied on the input of the schedule.
-
final
def
whileInputM[A1 <: A](f: (A1) ⇒ UIO[Boolean]): Schedule[R, A1, B]
Returns a new schedule that continues this schedule so long as the effectful predicate is satisfied on the input of the schedule.
-
final
def
whileOutput(f: (B) ⇒ Boolean): Schedule[R, A, B]
Returns a new schedule that continues this schedule so long as the predicate is satisfied on the output value of the schedule.
-
final
def
whileOutputM(f: (B) ⇒ UIO[Boolean]): Schedule[R, A, B]
Returns a new schedule that continues this schedule so long as the effectful predicate is satisfied on the output value of the schedule.
-
final
def
zip[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, (B, C)]
Named alias for
<*>
. -
final
def
zipLeft[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, B]
Named alias for
<*
. -
final
def
zipRight[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, C]
Named alias for
*>
. -
final
def
||[R1 <: R, A1 <: A, C](that: Schedule[R1, A1, C]): Schedule[R1, A1, (B, C)]
Returns a new schedule that continues as long as either schedule continues, using the minimum of the delays of the two schedules.
-
final
def
|||[R1 <: R, B1 >: B, C](that: Schedule[R1, C, B1]): Schedule[R1, Either[A, C], B1]
Chooses between two schedules with a common output.