LayerModule
PackageAxial.Layers
Summary
| Name | Signature | Synopsis |
|---|---|---|
| fromAsync | Layer.fromAsync operation | Creates a layer from a raw async provisioning function. |
| fromValueTask | Layer.fromValueTask operation | Creates a layer from a raw value task provisioning function. |
| fromTask | Layer.fromTask operation | Creates a layer from a raw task provisioning function. |
| succeed | Layer.succeed value | Creates a layer that succeeds with a fixed output value. |
| envWith | Layer.envWith projection | Projects part of the input environment into the layer output. |
| addFinalizer | Layer.addFinalizer finalizer | Registers an asynchronous finalizer with the layer scope. |
| acquireRelease | Layer.acquireRelease acquire release | Acquires a resource and registers its release with the layer scope. |
| map | Layer.map mapper layer | Maps the successful output of a layer. |
| mapError | Layer.mapError mapper layer | Maps the typed provisioning failure of a layer. |
| bind | Layer.bind binder layer | Sequences layer provisioning with a dependent follow-up layer. |
| zip | Layer.zip left right | Builds two layers from the same input and scope and returns both outputs. |
| zipPar | Layer.zipPar left right | Builds two independent layers in parallel and returns both outputs. |
| merge | Layer.merge left right | Merges two independent service layers in parallel. |
| map2 | Layer.map2 mapper left right | Combines two layers with a mapping function. |
| apply | Layer.apply layer value | Applies a layer-wrapped function to a layer-wrapped value. |
| map3 | Layer.map3 mapper left middle right | Combines three layers with a mapping function. |
| provide | Layer.provide layer flow | Builds an environment with a layer, runs a downstream flow, and always closes the layer scope. |
Creates a layer from a raw async provisioning function.
Parameters
| Name | Type | Description |
|---|---|---|
| operation | 'input * Scope -> CancellationToken -> Async<Exit<'output, 'error>> |
Returns
Layer<'input, 'error, 'output>
Creates a layer from a raw value task provisioning function.
Parameters
| Name | Type | Description |
|---|---|---|
| operation | 'input * Scope -> CancellationToken -> ValueTask<Exit<'output, 'error>> |
Returns
Layer<'input, 'error, 'output>
Creates a layer from a raw task provisioning function.
Parameters
| Name | Type | Description |
|---|---|---|
| operation | 'input * Scope -> CancellationToken -> Task<Exit<'output, 'error>> |
Returns
Layer<'input, 'error, 'output>
Creates a layer that succeeds with a fixed output value.
Parameters
| Name | Type | Description |
|---|---|---|
| value | 'output |
Returns
Layer<'input, 'error, 'output>
Projects part of the input environment into the layer output.
Parameters
| Name | Type | Description |
|---|---|---|
| projection | 'input -> 'output |
Returns
Layer<'input, 'error, 'output>
Registers an asynchronous finalizer with the layer scope.
Parameters
| Name | Type | Description |
|---|---|---|
| finalizer | Finalizer | The finalizer to run when the layer scope closes. |
Returns
Layer<'input, 'error, unit>
Acquires a resource and registers its release with the layer scope.
Parameters
| Name | Type | Description |
|---|---|---|
| acquire | Layer<'input, 'error, 'resource> | The layer that acquires the resource. |
| release | 'resource -> Finalizer | The release action to run when the layer scope closes. |
Returns
Layer<'input, 'error, 'resource>
Maps the successful output of a layer.
Parameters
| Name | Type | Description |
|---|---|---|
| mapper | 'output -> 'next | |
| layer | Layer<'input, 'error, 'output> |
Returns
Layer<'input, 'error, 'next>
Maps the typed provisioning failure of a layer.
Parameters
| Name | Type | Description |
|---|---|---|
| mapper | 'error -> 'nextError | |
| layer | Layer<'input, 'error, 'output> |
Returns
Layer<'input, 'nextError, 'output>
Sequences layer provisioning with a dependent follow-up layer.
Parameters
| Name | Type | Description |
|---|---|---|
| binder | 'output -> Layer<'input, 'error, 'next> | |
| layer | Layer<'input, 'error, 'output> |
Returns
Layer<'input, 'error, 'next>
Builds two layers from the same input and scope and returns both outputs.
Parameters
| Name | Type | Description |
|---|---|---|
| left | Layer<'input, 'error, 'left> | |
| right | Layer<'input, 'error, 'right> |
Returns
Layer<'input, 'error, ('left * 'right)>
Builds two independent layers in parallel and returns both outputs.
Parameters
| Name | Type | Description |
|---|---|---|
| left | Layer<'input, 'error, 'left> | |
| right | Layer<'input, 'error, 'right> |
Returns
Layer<'input, 'error, ('left * 'right)>
Merges two independent service layers in parallel.
Parameters
| Name | Type | Description |
|---|---|---|
| left | Layer<'input, 'error, 'left> | |
| right | Layer<'input, 'error, 'right> |
Returns
Layer<'input, 'error, ('left * 'right)>
Combines two layers with a mapping function.
Parameters
| Name | Type | Description |
|---|---|---|
| mapper | 'left -> 'right -> 'output | |
| left | Layer<'input, 'error, 'left> | |
| right | Layer<'input, 'error, 'right> |
Returns
Layer<'input, 'error, 'output>
Applies a layer-wrapped function to a layer-wrapped value.
Parameters
| Name | Type | Description |
|---|---|---|
| layer | Layer<'input, 'error, ('value -> 'next)> | |
| value | Layer<'input, 'error, 'value> |
Returns
Layer<'input, 'error, 'next>
Combines three layers with a mapping function.
Parameters
| Name | Type | Description |
|---|---|---|
| mapper | 'left -> 'middle -> 'right -> 'output | |
| left | Layer<'input, 'error, 'left> | |
| middle | Layer<'input, 'error, 'middle> | |
| right | Layer<'input, 'error, 'right> |
Returns
Layer<'input, 'error, 'output>
Builds an environment with a layer, runs a downstream flow, and always closes the layer scope.
Parameters
| Name | Type | Description |
|---|---|---|
| layer | Layer<'input, 'error, 'environment> | The layer that builds the downstream environment. |
| flow | Flow<'environment, 'error, 'value> | The flow to run with the provided environment. |
Returns
Flow<'input, 'error, 'value>
Verification Examples
let program () =
let runtimeLayer = Layer.succeed "production"
let workflow = Flow.envWith String.length
Layer.provide runtimeLayer workflow
