Package-level declarations
Types
A CircuitBreaker is used to protect
resources or services from being overloaded When a service is being overloaded, interacting with it more will only worsen its overloaded state. Especially when combined with retry mechanisms such as Schedule, in some cases simply using a back-off retry policy might not be sufficient during peak traffics.
CountDownLatch allows for awaiting a given number of countdown signals. Models the behavior of java.util.concurrent.CountDownLatch in Kotlin with suspend
.
A CyclicBarrier is a synchronization mechanism that allows a set of coroutines to wait for each other to reach a certain point before continuing execution. It is called a "cyclic" barrier because it can be reused after all coroutines have reached the barrier and released.
Resource models resource allocation and releasing. It is especially useful when multiple resources that depend on each other need to be acquired and later released in reverse order. The capability of installing resources is called ResourceScope, and Resource defines the value associating the acquisition
step, and the finalizer
. Resource allocates and releases resources in a safe way that co-operates with Structured Concurrency, and KotlinX Coroutines.
A common demand when working with effects is to retry or repeat them when certain circumstances happen. Usually, the retrial or repetition does not happen right away; rather, it is done based on a policy. For instance, when fetching content from a network request, we may want to retry it when it fails, using an exponential backoff algorithm, for a maximum of 15 seconds or 5 attempts, whatever happens first.
Functions
Creates a Resource from an AutoCloseable, which uses AutoCloseable.close for releasing.
Describes a task with safe resource acquisition and release in the face of errors and interruption. It would be the equivalent of an async capable try/catch/finally
statements in mainstream imperative languages for resource acquisition and release.
A way to safely acquire a resource and release in the face of errors and cancellation. It uses ExitCase to distinguish between different exit cases when releasing the acquired resource.
Creates a Resource from an Closeable, which uses Closeable.close for releasing.
Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.
Flow that emits Unit every period while taking into account how much time it takes downstream to consume the emission. If downstream takes longer to process than period than it immediately emits another Unit, if you set dampen to false it will send n = downstreamTime / period
Unit elements immediately.
Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.
Like map, but will evaluate transform in parallel, emitting the results downstream in the same order as the input stream. The number of concurrent effects is limited by concurrency.
Like map, but will evaluate effects in parallel, emitting the results downstream. The number of concurrent effects is limited by concurrency.
Sequences all tasks in parallel on Dispatchers.Default and return the result
Sequences all tasks in parallel and return the result
Sequences all tasks in parallel on Dispatchers.Default and return the result. If one of the tasks returns Either.Left, then it will short-circuit the operation and cancelling all this running tasks, and returning the first encountered Either.Left.
Sequences all tasks in parallel on ctx and return the result. If one of the tasks returns Either.Left, then it will short-circuit the operation and cancelling all this running tasks, and returning the first encountered Either.Left.
Sequences all tasks in n parallel processes on Dispatchers.Default and return the result.
Sequences all tasks in n parallel processes on Dispatchers.Default and return the result.
Sequences all tasks in n parallel processes and return the result.
Sequences all tasks in parallel on ctx and returns the result. If one or more of the tasks returns Result.failure then all the Result.failure results will be combined using addSuppressed.
Traverses this Iterable and runs suspend CoroutineScope.() -> Result<A>
in n parallel operations on CoroutineContext. If one or more of the tasks returns Result.failure then all the Result.failure results will be combined using addSuppressed.
Sequences all tasks in parallel on Dispatchers.Default and returns the result. If one or more of the tasks returns Validated.Invalid then all the Validated.Invalid results will be combined using semigroup.
Sequences all tasks in parallel on ctx and returns the result. If one or more of the tasks returns Validated.Invalid then all the Validated.Invalid results will be combined using semigroup.
Traverses this Iterable and runs f in n parallel operations on CoroutineContext. If one or more of the tasks returns Validated.Invalid then all the Validated.Invalid results will be combined using semigroup.
Traverses this Iterable and runs all mappers f on Dispatchers.Default. Cancelling this operation cancels all running tasks.
Traverses this Iterable and runs all mappers f on CoroutineContext.
Traverses this Iterable and runs all mappers f on Dispatchers.Default. If one of the f returns Either.Left, then it will short-circuit the operation and cancelling all this running f, and returning the first encountered Either.Left.
Traverses this Iterable and runs all mappers f on CoroutineContext. If one of the f returns Either.Left, then it will short-circuit the operation and cancelling all this running f, and returning the first encountered Either.Left.
Traverses this Iterable and runs f in n parallel operations on Dispatchers.Default. If one of the f returns Either.Left, then it will short-circuit the operation and cancelling all this running f, and returning the first encountered Either.Left.
Traverses this Iterable and runs all mappers f on Dispatchers.Default. If one or more of the f returns Result.failure then all the Result.failure results will be combined using addSuppressed.
Traverses this Iterable and runs all mappers f on CoroutineContext. If one or more of the f returns Result.failure then all the Result.failure results will be combined using addSuppressed.
Traverses this Iterable and runs f in n parallel operations on Dispatchers.Default. If one or more of the f returns Result.failure then all the Result.failure results will be combined using addSuppressed.
Traverses this Iterable and runs f in n parallel operations on CoroutineContext. If one or more of the f returns Result.failure then all the Result.failure results will be combined using addSuppressed.
Traverses this Iterable and runs all mappers f on Dispatchers.Default. If one or more of the f returns Validated.Invalid then all the Validated.Invalid results will be combined using semigroup.
Traverses this Iterable and runs all mappers f on CoroutineContext. If one or more of the f returns Validated.Invalid then all the Validated.Invalid results will be combined using semigroup.
Traverses this Iterable and runs f in n parallel operations on Dispatchers.Default. If one or more of the f returns Validated.Invalid then all the Validated.Invalid results will be combined using semigroup.
Traverses this Iterable and runs f in n parallel operations on CoroutineContext. If one or more of the f returns Validated.Invalid then all the Validated.Invalid results will be combined using semigroup.
Runs fa, fb in parallel on Dispatchers.Default and combines their results using the provided function.
Runs fa, fb, fc in parallel on Dispatchers.Default and combines their results using the provided function.
Runs fa, fb, fc, fd in parallel on Dispatchers.Default and combines their results using the provided function.
Runs fa, fb, fc, fd, fe in parallel on Dispatchers.Default and combines their results using the provided function.
Runs fa, fb, fc, fd, fe, ff in parallel on Dispatchers.Default and combines their results using the provided function.
Runs fa, fb, fc, fd, fe, ff in parallel on ctx and combines their results using the provided function.
Runs fa, fb, fc, fd, fe, ff, fg in parallel on Dispatchers.Default and combines their results using the provided function.
Runs fa, fb, fc, fd, fe, ff, fg in parallel on ctx and combines their results using the provided function.
Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on Dispatchers.Default and combines their results using the provided function.
Races the participants fa, fb in parallel on the Dispatchers.Default. The winner of the race cancels the other participants. Cancelling the operation cancels all participants. An uncancellable participant will back-pressure the result of raceN.
Races the participants fa, fb on the provided CoroutineContext. The winner of the race cancels the other participants. Cancelling the operation cancels all participants.
Races the participants fa, fb&fc in parallel on the Dispatchers.Default. The winner of the race cancels the other participants. Cancelling the operation cancels all participants.
Races the participants fa, fb&fc on the provided CoroutineContext. The winner of the race cancels the other participants. Cancelling the operation cancels all participants.
Composes a releaseCase action to a Resource.use action creating a Resource.
Runs an effect and, if it fails, decide using the provided policy if the effect should be retried and if so, with how much delay. Returns the result of the effect if if it was successful or re-raises the last error encountered when the schedule ends.
Retries collection of the given flow when an exception occurs in the upstream flow based on a decision by the schedule. This operator is transparent to exceptions that occur in downstream flow and does not retry on exceptions that are thrown to cancel the flow.
Runs an effect and, if it fails, decide using the provided policy if the effect should be retried and if so, with how much delay. Also offers a function to handle errors if they are encountered during retrial.
Runs an effect and, if it fails, decide using the provided policy if the effect should be retried and if so, with how much delay. Also offers a function to handle errors if they are encountered during retrial.
Creates a single threaded CoroutineContext as a Resource. Upon release an orderly shutdown of the ExecutorService takes place in which previously submitted tasks are executed, but no new tasks will be accepted.
Gets current system time in milliseconds since certain moment in the past, only delta between two subsequent calls makes sense.