Package arrow.fx.coroutines

Types

Link copied to clipboard
interface Atomic<A>

An Atomic with an initial value of A.

Link copied to clipboard
class CircuitBreaker

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.

Link copied to clipboard
sealed class ExitCase
Link copied to clipboard
object Platform
Link copied to clipboard
sealed class Race3<out A, out B, out C>
Link copied to clipboard
sealed class Resource<out A>

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. Or when you want to load independent resources in parallel.

Link copied to clipboard
sealed class Schedule<Input, Output>

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.

Link copied to clipboard
inline class Use<A>(acquire: suspend () -> A)

Marker for suspend () -> A to be marked as the Use action of a Resource. Offers a convenient DSL to use Resource for simple resources.

Functions

Link copied to clipboard
fun <A> Resource<A>.asFlow(): <ERROR CLASS><A>

runs Resource.use and emits A of the resource

Link copied to clipboard
inline suspend fun <A, B> bracket(    crossinline acquire: suspend () -> A,     use: suspend (A) -> B,     crossinline release: suspend (A) -> Unit): B

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.

Link copied to clipboard
inline suspend fun <A, B> bracketCase(    crossinline acquire: suspend () -> A,     use: suspend (A) -> B,     crossinline release: suspend (A, ExitCase) -> Unit): B

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.

Link copied to clipboard
fun fixedRate(    period: Long,     dampen: Boolean = true,     timeStampInMillis: () -> Long = { timeInMillis() }): <ERROR CLASS><Unit>

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 / periodUnit elements immediately.

fun fixedRate(    period: Duration,     dampen: Boolean = true,     timeStampInMillis: () -> Long = { timeInMillis() }): <ERROR CLASS><Unit>
Link copied to clipboard
fun <A : AutoCloseable> Resource.Companion.fromAutoCloseable(f: suspend () -> A): Resource<A>

Creates a Resource from an AutoCloseable, which uses AutoCloseable.close for releasing.

Link copied to clipboard
fun <A : Closeable> Resource.Companion.fromCloseable(f: suspend () -> A): Resource<A>

Creates a Resource from an Closeable, which uses Closeable.close for releasing.

Link copied to clipboard
fun Resource.Companion.fromExecutor(f: suspend () -> ExecutorService): Resource<CoroutineContext>

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.

Link copied to clipboard
inline suspend fun <A> guarantee(fa: suspend () -> A, crossinline finalizer: suspend () -> Unit): A

Guarantees execution of a given finalizer after fa regardless of success, error or cancellation.

Link copied to clipboard
inline suspend fun <A> guaranteeCase(fa: suspend () -> A, crossinline finalizer: suspend (ExitCase) -> Unit): A

Guarantees execution of a given finalizer after fa regardless of success, error or cancellation, allowing for differentiating between exit conditions with the ExitCase argument of the finalizer.

Link copied to clipboard
inline fun <A, B> <ERROR CLASS><A>.mapIndexed(crossinline f: suspend (Int, A) -> B): <ERROR CLASS><B>
Link copied to clipboard
fun <A> <ERROR CLASS><A>.metered(period: Long): <ERROR CLASS><A>

fun <A> <ERROR CLASS><A>.metered(period: Duration): <ERROR CLASS><A>

Flow that emits A 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 A.

Link copied to clipboard
suspend fun <A> never(): A
Link copied to clipboard
inline suspend fun <A> onCancel(fa: suspend () -> A, crossinline onCancel: suspend () -> Unit): A

Registers an onCancel handler after fa. onCancel is guaranteed to be called in case of cancellation, otherwise it's ignored.

Link copied to clipboard
inline fun <A, B> <ERROR CLASS><A>.parMap(concurrency: Int = DEFAULT_CONCURRENCY, crossinline transform: suspend <ERROR CLASS>.(A) -> B): <ERROR CLASS><B>

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.

Link copied to clipboard
inline fun <A, B> <ERROR CLASS><A>.parMapUnordered(concurrency: Int = DEFAULT_CONCURRENCY, crossinline transform: suspend (A) -> B): <ERROR CLASS><B>

Like map, but will evaluate effects in parallel, emitting the results downstream. The number of concurrent effects is limited by concurrency.

Link copied to clipboard
suspend fun <A> Iterable<suspend () -> A>.parSequence(): List<A>
suspend fun <A> Iterable<suspend () -> A>.parSequence(ctx: CoroutineContext = EmptyCoroutineContext): List<A>

@JvmName(name = "parSequenceScoped")
suspend fun <A> Iterable<suspend <ERROR CLASS>.() -> A>.parSequence(): List<A>

Sequences all tasks in parallel on Dispatchers.Default and return the result

@JvmName(name = "parSequenceScoped")
suspend fun <A> Iterable<suspend <ERROR CLASS>.() -> A>.parSequence(ctx: CoroutineContext = EmptyCoroutineContext): List<A>

Sequences all tasks in parallel and return the result

Link copied to clipboard
suspend fun <A, B> Iterable<suspend () -> <ERROR CLASS><A, B>>.parSequenceEither(): <ERROR CLASS><A, List<B>>

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.

@JvmName(name = "parSequenceEitherScoped")
suspend fun <A, B> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><A, B>>.parSequenceEither(): <ERROR CLASS><A, List<B>>
suspend fun <A, B> Iterable<suspend () -> <ERROR CLASS><A, B>>.parSequenceEither(ctx: CoroutineContext = EmptyCoroutineContext): <ERROR CLASS><A, List<B>>

@JvmName(name = "parSequenceEitherScoped")
suspend fun <A, B> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><A, B>>.parSequenceEither(ctx: CoroutineContext = EmptyCoroutineContext): <ERROR CLASS><A, List<B>>

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.

Link copied to clipboard
suspend fun <A, B> Iterable<suspend () -> <ERROR CLASS><A, B>>.parSequenceEitherN(n: Int): <ERROR CLASS><A, List<B>>

Sequences all tasks in n parallel processes on Dispatchers.Default and return the result.

@JvmName(name = "parSequenceEitherNScoped")
suspend fun <A, B> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><A, B>>.parSequenceEitherN(n: Int): <ERROR CLASS><A, List<B>>
suspend fun <A, B> Iterable<suspend () -> <ERROR CLASS><A, B>>.parSequenceEitherN(ctx: CoroutineContext = EmptyCoroutineContext, n: Int): <ERROR CLASS><A, List<B>>

@JvmName(name = "parSequenceEitherNScoped")
suspend fun <A, B> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><A, B>>.parSequenceEitherN(ctx: CoroutineContext = EmptyCoroutineContext, n: Int): <ERROR CLASS><A, List<B>>

Sequences all tasks in n parallel processes on ctx and return the result.

Link copied to clipboard
suspend fun <A> Iterable<suspend () -> A>.parSequenceN(n: Int): List<A>
suspend fun <A> Iterable<suspend () -> A>.parSequenceN(ctx: CoroutineContext = EmptyCoroutineContext, n: Int): List<A>

@JvmName(name = "parSequenceNScoped")
suspend fun <A> Iterable<suspend <ERROR CLASS>.() -> A>.parSequenceN(n: Int): List<A>

Sequences all tasks in n parallel processes on Dispatchers.Default and return the result.

@JvmName(name = "parSequenceNScoped")
suspend fun <A> Iterable<suspend <ERROR CLASS>.() -> A>.parSequenceN(ctx: CoroutineContext = EmptyCoroutineContext, n: Int): List<A>

Sequences all tasks in n parallel processes and return the result.

Link copied to clipboard
suspend fun <A> Iterable<suspend () -> Result<A>>.parSequenceResult(ctx: CoroutineContext = EmptyCoroutineContext): Result<List<A>>

@JvmName(name = "parSequenceResultScoped")
suspend fun <A> Iterable<suspend <ERROR CLASS>.() -> Result<A>>.parSequenceResult(ctx: CoroutineContext = EmptyCoroutineContext): Result<List<A>>

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.

Link copied to clipboard
suspend fun <A> Iterable<suspend () -> Result<A>>.parSequenceResultN(n: Int): Result<List<A>>
suspend fun <A> Iterable<suspend () -> Result<A>>.parSequenceResultN(ctx: CoroutineContext = EmptyCoroutineContext, n: Int): Result<List<A>>

@JvmName(name = "parSequenceResultNScoped")
suspend fun <A> Iterable<suspend <ERROR CLASS>.() -> Result<A>>.parSequenceResultN(n: Int): Result<List<A>>
@JvmName(name = "parSequenceResultNScoped")
suspend fun <A> Iterable<suspend <ERROR CLASS>.() -> Result<A>>.parSequenceResultN(ctx: CoroutineContext = EmptyCoroutineContext, n: Int): Result<List<A>>

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.

Link copied to clipboard
suspend fun <E, A> Iterable<suspend () -> <ERROR CLASS><E, A>>.parSequenceValidated(semigroup: <ERROR CLASS><E>): <ERROR CLASS><E, List<A>>
suspend fun <E, A> Iterable<suspend () -> <ERROR CLASS><E, A>>.parSequenceValidated(ctx: CoroutineContext = EmptyCoroutineContext, semigroup: <ERROR CLASS><E>): <ERROR CLASS><E, List<A>>

@JvmName(name = "parSequenceValidatedScoped")
suspend fun <E, A> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><E, A>>.parSequenceValidated(semigroup: <ERROR CLASS><E>): <ERROR CLASS><E, List<A>>

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.

@JvmName(name = "parSequenceValidatedScoped")
suspend fun <E, A> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><E, A>>.parSequenceValidated(ctx: CoroutineContext = EmptyCoroutineContext, semigroup: <ERROR CLASS><E>): <ERROR CLASS><E, List<A>>

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.

Link copied to clipboard
suspend fun <E, A> Iterable<suspend () -> <ERROR CLASS><E, A>>.parSequenceValidatedN(semigroup: <ERROR CLASS><E>, n: Int): <ERROR CLASS><E, List<A>>
suspend fun <E, A> Iterable<suspend () -> <ERROR CLASS><E, A>>.parSequenceValidatedN(    ctx: CoroutineContext = EmptyCoroutineContext,     semigroup: <ERROR CLASS><E>,     n: Int): <ERROR CLASS><E, List<A>>

@JvmName(name = "parSequenceValidatedNScoped")
suspend fun <E, A> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><E, A>>.parSequenceValidatedN(semigroup: <ERROR CLASS><E>, n: Int): <ERROR CLASS><E, List<A>>
@JvmName(name = "parSequenceValidatedNScoped")
suspend fun <E, A> Iterable<suspend <ERROR CLASS>.() -> <ERROR CLASS><E, A>>.parSequenceValidatedN(    ctx: CoroutineContext = EmptyCoroutineContext,     semigroup: <ERROR CLASS><E>,     n: Int): <ERROR CLASS><E, List<A>>

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.

Link copied to clipboard
suspend fun <A, B> Iterable<A>.parTraverse(f: suspend <ERROR CLASS>.(A) -> B): List<B>

Traverses this Iterable and runs all mappers f on Dispatchers.Default. Cancelling this operation cancels all running tasks.

suspend fun <A, B> Iterable<A>.parTraverse(ctx: CoroutineContext = EmptyCoroutineContext, f: suspend <ERROR CLASS>.(A) -> B): List<B>

Traverses this Iterable and runs all mappers f on CoroutineContext.

Link copied to clipboard
suspend fun <A, B, E> Iterable<A>.parTraverseEither(f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>

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.

suspend fun <A, B, E> Iterable<A>.parTraverseEither(ctx: CoroutineContext = EmptyCoroutineContext, f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>

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.

Link copied to clipboard
suspend fun <A, B, E> Iterable<A>.parTraverseEitherN(n: Int, f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>
suspend fun <A, B, E> Iterable<A>.parTraverseEitherN(    ctx: CoroutineContext = EmptyCoroutineContext,     n: Int,     f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>

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.

Link copied to clipboard
suspend fun <A, B> Iterable<A>.parTraverseN(n: Int, f: suspend <ERROR CLASS>.(A) -> B): List<B>

Traverses this Iterable and runs f in n parallel operations on Dispatchers.Default. Cancelling this operation cancels all running tasks.

suspend fun <A, B> Iterable<A>.parTraverseN(    ctx: CoroutineContext = EmptyCoroutineContext,     n: Int,     f: suspend <ERROR CLASS>.(A) -> B): List<B>

Traverses this Iterable and runs f in n parallel operations on ctx.

Link copied to clipboard
suspend fun <A, B> Iterable<A>.parTraverseResult(f: suspend <ERROR CLASS>.(A) -> Result<B>): Result<List<B>>

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.

suspend fun <A, B> Iterable<A>.parTraverseResult(ctx: CoroutineContext = EmptyCoroutineContext, f: suspend <ERROR CLASS>.(A) -> Result<B>): Result<List<B>>

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.

Link copied to clipboard
suspend fun <A, B> Iterable<A>.parTraverseResultN(n: Int, f: suspend <ERROR CLASS>.(A) -> Result<B>): Result<List<B>>

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.

suspend fun <A, B> Iterable<A>.parTraverseResultN(    ctx: CoroutineContext = EmptyCoroutineContext,     n: Int,     f: suspend <ERROR CLASS>.(A) -> Result<B>): Result<List<B>>

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.

Link copied to clipboard
suspend fun <E, A, B> Iterable<A>.parTraverseValidated(semigroup: <ERROR CLASS><E>, f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>

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.

suspend fun <E, A, B> Iterable<A>.parTraverseValidated(    ctx: CoroutineContext = EmptyCoroutineContext,     semigroup: <ERROR CLASS><E>,     f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>

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.

Link copied to clipboard
suspend fun <E, A, B> Iterable<A>.parTraverseValidatedN(    semigroup: <ERROR CLASS><E>,     n: Int,     f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>

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.

suspend fun <E, A, B> Iterable<A>.parTraverseValidatedN(    ctx: CoroutineContext = EmptyCoroutineContext,     semigroup: <ERROR CLASS><E>,     n: Int,     f: suspend <ERROR CLASS>.(A) -> <ERROR CLASS><E, B>): <ERROR CLASS><E, List<B>>

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.

Link copied to clipboard
inline suspend fun <A, B, C> parZip(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline f: suspend <ERROR CLASS>.(A, B) -> C): C

Runs fa, fb in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline f: suspend <ERROR CLASS>.(A, B) -> C): C

Runs fa, fb in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D> parZip(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline f: suspend <ERROR CLASS>.(A, B, C) -> D): D

Runs fa, fb, fc in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline f: suspend <ERROR CLASS>.(A, B, C) -> D): D

Runs fa, fb, fc in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E> parZip(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D) -> E): E

Runs fa, fb, fc, fd in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D) -> E): E

Runs fa, fb, fc, fd in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F> parZip(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E) -> F): F

Runs fa, fb, fc, fd, fe in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E) -> F): F

Runs fa, fb, fc, fd, fe in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G> parZip(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline ff: suspend <ERROR CLASS>.() -> F,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E, F) -> G): G

Runs fa, fb, fc, fd, fe, ff in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline ff: suspend <ERROR CLASS>.() -> F,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E, F) -> G): G

Runs fa, fb, fc, fd, fe, ff in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H> parZip(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline ff: suspend <ERROR CLASS>.() -> F,     crossinline fg: suspend <ERROR CLASS>.() -> G,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E, F, G) -> H): H

Runs fa, fb, fc, fd, fe, ff, fg in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline ff: suspend <ERROR CLASS>.() -> F,     crossinline fg: suspend <ERROR CLASS>.() -> G,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E, F, G) -> H): H

Runs fa, fb, fc, fd, fe, ff, fg in parallel on ctx and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H, I> parZip(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline ff: suspend <ERROR CLASS>.() -> F,     crossinline fg: suspend <ERROR CLASS>.() -> G,     crossinline fh: suspend <ERROR CLASS>.() -> H,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E, F, G, H) -> I): I

Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on Dispatchers.Default and combines their results using the provided function.

inline suspend fun <A, B, C, D, E, F, G, H, I> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C,     crossinline fd: suspend <ERROR CLASS>.() -> D,     crossinline fe: suspend <ERROR CLASS>.() -> E,     crossinline ff: suspend <ERROR CLASS>.() -> F,     crossinline fg: suspend <ERROR CLASS>.() -> G,     crossinline fh: suspend <ERROR CLASS>.() -> H,     crossinline f: suspend <ERROR CLASS>.(A, B, C, D, E, F, G, H) -> I): I

Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on ctx and combines their results using the provided function.

Link copied to clipboard
inline suspend fun <A, B> raceN(crossinline fa: suspend <ERROR CLASS>.() -> A, crossinline fb: suspend <ERROR CLASS>.() -> B): <ERROR CLASS><A, B>

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.

inline suspend fun <A, B> raceN(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B): <ERROR CLASS><A, B>

Races the participants fa, fb on the provided CoroutineContext. The winner of the race cancels the other participants. Cancelling the operation cancels all participants.

inline suspend fun <A, B, C> raceN(    crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C): Race3<A, B, C>

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.

inline suspend fun <A, B, C> raceN(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend <ERROR CLASS>.() -> A,     crossinline fb: suspend <ERROR CLASS>.() -> B,     crossinline fc: suspend <ERROR CLASS>.() -> C): Race3<A, B, C>

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.

Link copied to clipboard
infix fun <A> Resource<A>.release(release: suspend (A) -> Unit): Resource<A>

Composes a release action to a Resource.use action creating a Resource.

infix fun <A> Use<A>.release(release: suspend (A) -> Unit): Resource<A>
Link copied to clipboard
infix fun <A> Resource<A>.releaseCase(release: suspend (A, ExitCase) -> Unit): Resource<A>

Composes a releaseCase action to a Resource.use action creating a Resource.

infix fun <A> Use<A>.releaseCase(release: suspend (A, ExitCase) -> Unit): Resource<A>
Link copied to clipboard
fun <A> <ERROR CLASS><A>.repeat(): <ERROR CLASS><A>

Repeats the Flow forever

Link copied to clipboard
fun <A> resource(acquire: suspend () -> A): Use<A>

Marks an acquire operation as the Resource.use step of a Resource.

Link copied to clipboard
fun <A, B> <ERROR CLASS><A>.retry(schedule: Schedule<Throwable, B>): <ERROR CLASS><A>

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.

suspend fun <A, B> Schedule<Throwable, B>.retry(fa: suspend () -> A): A

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.

Link copied to clipboard
suspend fun <A, B> Schedule<Throwable, B>.retryOrElse(fa: suspend () -> A, orElse: suspend (Throwable, B) -> A): A

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.

Link copied to clipboard
suspend fun <A, B, C> Schedule<Throwable, B>.retryOrElseEither(fa: suspend () -> A, orElse: suspend (Throwable, B) -> C): <ERROR CLASS><C, A>

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.

Link copied to clipboard
inline fun <A> Iterable<Resource<A>>.sequence(): Resource<List<A>>

Sequences this Iterable of Resources. Iterable.map and sequence is equivalent to traverseResource.

Link copied to clipboard
fun Resource.Companion.singleThreadContext(name: String): Resource<CoroutineContext>

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.

Link copied to clipboard
expect fun timeInMillis(): Long
actual fun timeInMillis(): Long
actual fun timeInMillis(): Long
actual fun timeInMillis(): Long
Link copied to clipboard
inline fun <A, B> Iterable<A>.traverseResource(crossinline f: (A) -> Resource<B>): Resource<List<B>>

Traverse this Iterable and collects the resulting Resource<B> of f into a Resource<List<B>>.

Link copied to clipboard
suspend fun unit()