Effect Module
Functions for running, combining, recovering and repeating effects.
Functions and values
| Function or value |
Description
|
|
|
|
|
|
|
|
|
Full Usage:
Effect.fanOut size f s
Parameters:
int
-
The number of workers
f : IAsyncEnumerable<'a> -> Effect<'r, unit, ^err>
-
Creates the effect that processes a worker's items
s : IAsyncEnumerable<'a>
-
The items to distribute
Returns: Effect<'r, unit, ^err>
Modifiers: inline Type parameters: 'a, 'r, ^err (requires (static member op_Addition : ^err * ^err -> ^err)) |
Distributes the items of s over size workers, in turn, and runs the effect created by f for each worker, on the items it is given. The workers run concurrently, and the effect completes when they all have. When a worker fails, no more items are taken from s, the other workers are stopped where they are, and the effect fails with that worker's error (or exception). A worker that returns before its items end doesn't hold up the others: the items it would have been given are discarded. Each worker is given at most 10 items ahead of processing them.
Example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Full Usage:
Effect.mapParLimited limit s f
Parameters:
int
-
The most effects to run at a time, at least 1
s : Effect<'r, 'a, 'e> seq
-
The effects
f : Effect<'r, 'a, 'e> -> Effect<'r, 'b, 'e>
-
The function to apply to each effect
Returns: Effect<'r, 'b list, 'e>
Type parameters: 'r, 'a, 'e, 'b |
Applies f to each effect, and executes the results in parallel, at most
limit at a time, like
|
|
|
|
|
|
Executes effects in parallel, at most limit at a time, and collects their results in a list, in the order the effects were given. The effects are started in that order, the next one as soon as fewer than limit are running, without waiting for the others. Once one fails or throws, no more are started, and once those already running have completed, the result is the first error in that order, or the exception.
Example
module Seq
from Microsoft.FSharp.Collections
val map: mapping: ('T -> 'U) -> source: 'T seq -> 'U seq
|
|
|
|
|
|
|
|
|
|
|
|
|
Full Usage:
Effect.repeatUntilCancellation token e
Parameters:
CancellationToken
-
The token that stops the repetition
e : Effect<'a, unit, 'b>
-
The effect
Returns: Effect<'a, unit, 'b>
Modifiers: inline Type parameters: 'a, 'b |
Runs the effect repeatedly until token is cancelled, which is checked before every run. It stops at the first failure.
Example
|
|
|
|
|
|
|
Full Usage:
Effect.ret a
Parameters:
'a
-
The value to wrap in the effect
Returns: Effect<'r, 'a, 'e>
Modifiers: inline Type parameters: 'r, 'a, 'e |
|
|
|
|
|
|
|
|
Runs the effect again every time it fails with an error for which cond is true. It fails with the first error for which cond is false.
Example
|
Full Usage:
Effect.run env e
Parameters:
'r
-
The environment needed to start the effect
e : Effect<'r, 'a, 'e>
-
The effect to run
Returns: AsyncResult<'a, 'e>
Modifiers: inline Type parameters: 'r, 'a, 'e |
Starts the effect.
Example
val task: TaskBuilder
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
val id: obj
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
val err: obj
|
|
Starts the effect, and raises an exception if it fails, with the error's string representation as its
message. Prefer
|
|
|
|
|
|
Configures an effect to fail after a given amount of time, unless it has already succeeded. The original effect still executes.
Example
|
|
|
|
Potentially recovers a failed effect by producing an Result{'a, 'e} in case of failure. If the effect was already successful, f is never run.
|
|
|
Full Usage:
Effect.withCancellation ct eff
Parameters:
CancellationToken
-
The token that ends the wait
eff : Effect<'a, unit, 'b>
-
The effect
Returns: Effect<'a, unit, 'b>
Type parameters: 'a, 'b |
Completes successfully when ct is cancelled, without waiting for the effect to finish. The effect is not cancelled: it keeps running, and its result is ignored.
|
|
Runs the effect with an environment derived by f from the one the resulting effect is run with. Such as an effect needing a particular environment type, run in the environment of a scope, which inherits that type.
Example
val report: obj
|
Full Usage:
Effect.zip e1 e2 f
Parameters:
Effect<'r, 'a, ^e>
-
The first effect.
e2 : Effect<'r, 'b, ^e>
-
The second effect.
f : 'a * 'b -> 'g
-
Function to combine the result of the effects in case both succeeds.
Returns: Effect<'r, 'g, ^e>
Modifiers: inline Type parameters: 'r, 'a, ^e, 'b, 'g (requires (static member op_Addition : ^e * ^e -> ^e)) |
Zips two effects together, the resulting effect will fail if either of the effects failed. In case both failed, the error is combined. The effects will execute in parallel if possible.
|
Orsak