Skip to content

Commit

Permalink
Add release notes and increment minor
Browse files Browse the repository at this point in the history
  • Loading branch information
glucaci committed Apr 18, 2021
1 parent 8fd8bba commit 045cb49
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
55 changes: 55 additions & 0 deletions ReleaseNotes/3.4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Workflow Core 3.4.0

## Execute Workflow Middleware

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.

The following example illustrates how you can use a execute workflow middleware to build [prometheus](https://prometheus.io/) metrics.

Note that you use `WorkflowMiddlewarePhase.ExecuteWorkflow` to specify that it runs after each workflow execution.

**Important:** You should call `next` as part of the workflow middleware to ensure that the next workflow in the chain runs.

```cs
public class MetricsMiddleware : IWorkflowMiddleware
{
private readonly ConcurrentHashSet<string>() _suspendedWorkflows =
new ConcurrentHashSet<string>();

private readonly Counter _completed;
private readonly Counter _suspended;

public MetricsMiddleware()
{
_completed = Prometheus.Metrics.CreateCounter(
"workflow_completed", "Workflow completed");

_suspended = Prometheus.Metrics.CreateCounter(
"workflow_suspended", "Workflow suspended");
}

public WorkflowMiddlewarePhase Phase =>
WorkflowMiddlewarePhase.ExecuteWorkflow;

public Task HandleAsync(
WorkflowInstance workflow,
WorkflowDelegate next)
{
switch (workflow.Status)
{
case WorkflowStatus.Complete:
if (_suspendedWorkflows.TryRemove(workflow.Id))
{
_suspended.Dec();
}
_completed.Inc();
break;
case WorkflowStatus.Suspended:
_suspended.Inc();
break;
}

return next();
}
}
```
8 changes: 4 additions & 4 deletions src/WorkflowCore/WorkflowCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Description>Workflow Core is a light weight workflow engine targeting .NET Standard.</Description>
<Version>3.3.6</Version>
<AssemblyVersion>3.3.6.0</AssemblyVersion>
<FileVersion>3.3.6.0</FileVersion>
<Version>3.4.0</Version>
<AssemblyVersion>3.4.0.0</AssemblyVersion>
<FileVersion>3.4.0.0</FileVersion>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIconUrl>https://github.com/danielgerlag/workflow-core/raw/master/src/logo.png</PackageIconUrl>
<PackageVersion>3.3.6</PackageVersion>
<PackageVersion>3.4.0</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 045cb49

Please sign in to comment.