Swolfkrow 0.2.4
See the version list below for details.
dotnet add package Swolfkrow --version 0.2.4
NuGet\Install-Package Swolfkrow -Version 0.2.4
<PackageReference Include="Swolfkrow" Version="0.2.4" />
paket add Swolfkrow --version 0.2.4
#r "nuget: Swolfkrow, 0.2.4"
// Install Swolfkrow as a Cake Addin
#addin nuget:?package=Swolfkrow&version=0.2.4
// Install Swolfkrow as a Cake Tool
#tool nuget:?package=Swolfkrow&version=0.2.4
Swolfkrow
Swolfkrow (pronounced /ˈwɜː(r)kˌfləʊs/) is a DSL designed to declaratively compose asynchronous workflows based on the IAsyncEnumerable<out T>
interface.
Workflows
In the context of this library, an asynchronous workflow is defined as a function that takes any number of parameters, executes arbitrary business logic, and returns an asynchronous stream of events signaling progress, outcomes, and errors.
Usage
Workflow continuations
Asynchronous workflows can be composed as sequences of simpler workflows, where one workflow is continued by another:
public record SomeEvent(string Description);
IAsyncEnumerable<SomeEvent> Step1() { ... }
IAsyncEnumerable<SomeEvent> Step2(int someInfo) { ... }
IAsyncEnumerable<SomeEvent> ComposedWorkflow()
=> Workflow
.Start(Step1)
.Then(Step2, 42);
Stateful continuations
Workflow continuations can be based on state explicitly folded from the events yielded by the workflow:
public record SomeEvent(string Description);
IAsyncEnumerable<SomeEvent> Step1() { ... }
IAsyncEnumerable<SomeEvent> Step2(int someInfo) { ... }
IAsyncEnumerable<SomeEvent> ComposedWorkflow()
=> Workflow
.Start(Step1)
.Then(
createContinuation: currentState => currentState * 2,
computeNextState: (currentState, nextEvent) => currentState + 1,
initialState: 0);
Event continuations
Individual events yielded by an asynchronous workflow can be continued by other workflows that are intercalated right after:
public record SomeEvent(string Description);
IAsyncEnumerable<SomeEvent> Step1() { ... }
IAsyncEnumerable<SomeEvent> Step2(SomeEvent someEvent) { ... }
IAsyncEnumerable<SomeEvent> ComposedWorkflow()
=> Workflow
.Start(Step1)
.ThenForEach(Step2);
Optionally, it is possible to continue only events of a specific sub-type and/or that satisfy a predicate:
public record SomeEvent(string Description);
public record SomeSpecificEvent(string Description, ...) : SomeEvent(Description);
IAsyncEnumerable<SomeEvent> Step1() { ... }
IAsyncEnumerable<SomeEvent> Step2(SomeSpecificEvent someSpecificEvent) { ... }
bool ContinueIf(SomeSpecificEvent someSpecificEvent) { ... }
IAsyncEnumerable<SomeEvent> ComposedWorkflow()
=> Workflow
.Start(Step1)
.ThenForEach(Step2, ContinueIf);
Side effects
Side effects can be deliberately injected into an asynchronous workflow:
public record SomeEvent(string Description);
IAsyncEnumerable<SomeEvent> Step1() { ... }
IAsyncEnumerable<SomeEvent> Step2(int someInfo) { ... }
void LogEvent(SomeEvent someEvent)
=> Console.WriteLine($"Something happened: {SomeEvent}")
IAsyncEnumerable<SomeEvent> ComposedWorkflow()
=> Workflow
.Start(Step1)
.Then(Step2, 42)
.WithSideEffect(LogEvent);
Interruptions
Asynchronous workflows can be interrupted based on a condition computed on each of the yielded events:
public record SomeEvent(string Description);
public record SomeError(string Description, Exception Exception) : SomeEvent(Description);
IAsyncEnumerable<SomeEvent> Step1() { ... }
IAsyncEnumerable<SomeEvent> Step2(int someInfo) { ... }
bool IsError(SomeEvent nextEvent) => nextEvent is SomeError;
IAsyncEnumerable<SomeEvent> ComposedWorkflow()
=> Workflow
.Start(Step1)
.Then(Step2, 42)
.Until(IsError);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- System.Linq.Async (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.4.0 | 158 | 9/1/2023 |
0.3.2 | 145 | 7/22/2023 |
0.3.1 | 172 | 7/3/2023 |
0.3.0 | 157 | 7/2/2023 |
0.2.5 | 146 | 6/18/2023 |
0.2.4 | 147 | 6/12/2023 |
0.2.3 | 165 | 6/9/2023 |
0.2.2 | 162 | 6/6/2023 |
0.2.1 | 136 | 6/4/2023 |
0.2.0 | 148 | 5/29/2023 |
0.1.3 | 151 | 5/29/2023 |
0.1.2 | 153 | 5/25/2023 |
0.1.1 | 156 | 5/22/2023 |
0.1.0 | 151 | 5/21/2023 |
# 0.2.4 (2023-06-dd)
- Added interruptions.
# 0.2.3 (2023-06-10)
- Full review of the comment-based documentation.
- Added `IEnumerable` based overloads of start, continuation, and event continuation operators.
# 0.2.2 (2023-06-07)
- Added synchronous continuations.
# 0.2.1 (2023-06-04)
- Start/continue asynchronous workflows from `Task` and `ValueTask`
# 0.2.0 (2023-05-29)
- Simplified stateful continuations.
# 0.1.3 (2023-05-26)
- Added event continuations
# 0.1.2 (2023-05-25)
- Added `Start` and `Then` overloads with additional arguments
# 0.1.1 (2023-05-22)
- Added stateful continuations.
# 0.1.0 (2023-05-21)
- Initial Version.
- Added workflow continuations.