Build a new activity by applying f
to each value.
Build a new activity by applying f
to each value. When
f
is not defined for this activity's current value, the derived
activity becomes pending.
The activity which behaves as f
applied to Ok values.
Recover a failed activity.
Join two activities.
Map a T-typed activity to a U-typed one.
Map the states of a T-typed activity to a U-typed one.
Sample the current value of this activity.
Sample the current value of this activity. Sample throws an exception if the activity is in pending state or has failed.
Stabilize the value of this activity such that once an Ok value has been returned it stops error propagation and instead returns the last Ok value.
An Event of states.
The activity which behaves as f
to the state
of this activity.
An Event containing only nonpending values.
Activity, like Var, is a value that varies over time; but, richer than Var, these values have error and pending states. They are useful for modeling a process that produces values, but also intermittent failures (e.g. address resolution, reloadable configuration).
As such, an Activity can be in one of three states:
An Activity may transition between any state at any time. They are typically constructed from Events, but they can also be constructed without arguments.
As you can see, Activities start in a Pending state. Attempts to sample an Activity that is pending will fail. Curiously, the constructor for an Activity also returns a Witness.
Recall that a Witness is the interface to something that you can send values to; and in this case, that something is the Activity.
(For implementers, it may be useful to think of Activity as a monad transformer for an Op monad over Var where Op is like a Try with an additional pending state.)