Skip to content

Commit 045cb49

Browse files
committed
Add release notes and increment minor
1 parent 8fd8bba commit 045cb49

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

ReleaseNotes/3.4.0.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Workflow Core 3.4.0
2+
3+
## Execute Workflow Middleware
4+
5+
These middleware get run after each workflow execution and can be used to perform additional actions or build metrics/statistics for all workflows in your app.
6+
7+
The following example illustrates how you can use a execute workflow middleware to build [prometheus](https://prometheus.io/) metrics.
8+
9+
Note that you use `WorkflowMiddlewarePhase.ExecuteWorkflow` to specify that it runs after each workflow execution.
10+
11+
**Important:** You should call `next` as part of the workflow middleware to ensure that the next workflow in the chain runs.
12+
13+
```cs
14+
public class MetricsMiddleware : IWorkflowMiddleware
15+
{
16+
private readonly ConcurrentHashSet<string>() _suspendedWorkflows =
17+
new ConcurrentHashSet<string>();
18+
19+
private readonly Counter _completed;
20+
private readonly Counter _suspended;
21+
22+
public MetricsMiddleware()
23+
{
24+
_completed = Prometheus.Metrics.CreateCounter(
25+
"workflow_completed", "Workflow completed");
26+
27+
_suspended = Prometheus.Metrics.CreateCounter(
28+
"workflow_suspended", "Workflow suspended");
29+
}
30+
31+
public WorkflowMiddlewarePhase Phase =>
32+
WorkflowMiddlewarePhase.ExecuteWorkflow;
33+
34+
public Task HandleAsync(
35+
WorkflowInstance workflow,
36+
WorkflowDelegate next)
37+
{
38+
switch (workflow.Status)
39+
{
40+
case WorkflowStatus.Complete:
41+
if (_suspendedWorkflows.TryRemove(workflow.Id))
42+
{
43+
_suspended.Dec();
44+
}
45+
_completed.Inc();
46+
break;
47+
case WorkflowStatus.Suspended:
48+
_suspended.Inc();
49+
break;
50+
}
51+
52+
return next();
53+
}
54+
}
55+
```

src/WorkflowCore/WorkflowCore.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
1616
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1717
<Description>Workflow Core is a light weight workflow engine targeting .NET Standard.</Description>
18-
<Version>3.3.6</Version>
19-
<AssemblyVersion>3.3.6.0</AssemblyVersion>
20-
<FileVersion>3.3.6.0</FileVersion>
18+
<Version>3.4.0</Version>
19+
<AssemblyVersion>3.4.0.0</AssemblyVersion>
20+
<FileVersion>3.4.0.0</FileVersion>
2121
<PackageReleaseNotes></PackageReleaseNotes>
2222
<PackageIconUrl>https://github.com/danielgerlag/workflow-core/raw/master/src/logo.png</PackageIconUrl>
23-
<PackageVersion>3.3.6</PackageVersion>
23+
<PackageVersion>3.4.0</PackageVersion>
2424
</PropertyGroup>
2525

2626
<ItemGroup>

0 commit comments

Comments
 (0)