Skip to content

Commit cb3c5be

Browse files
authored
Merge branch 'master' into VKAlwaysWin/PersistantStorageWithCancellationToken
2 parents e3a49d2 + b84c9ce commit cb3c5be

File tree

423 files changed

+826
-1294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

423 files changed

+826
-1294
lines changed

.github/pull_request_template.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
**Describe the change**
3+
A clear and concise description of what the change is. Any PR submitted without a description of the change will not be reviewed.
4+
5+
**Describe your implementation or design**
6+
How did you go about implementing the change?
7+
8+
**Tests**
9+
Did you cover your changes with tests?
10+
11+
**Breaking change**
12+
Do you changes break compatibility with previous versions?
13+
14+
**Additional context**
15+
Any additional information you'd like to provide?

ReleaseNotes/3.4.0.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
TryDecrementSuspended(workflow);
42+
_completed.Inc();
43+
break;
44+
case WorkflowStatus.Suspended:
45+
_suspendedWorkflows.Add(workflow.Id);
46+
_suspended.Inc();
47+
break;
48+
default:
49+
TryDecrementSuspended(workflow);
50+
break;
51+
}
52+
53+
return next();
54+
}
55+
56+
private void TryDecrementSuspended(WorkflowInstance workflow)
57+
{
58+
if (_suspendedWorkflows.TryRemove(workflow.Id))
59+
{
60+
_suspended.Dec();
61+
}
62+
}
63+
}
64+
```

src/Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
<PropertyGroup>
3+
<PackageProjectUrl>https://github.com/danielgerlag/workflow-core</PackageProjectUrl>
4+
<PackageLicenseUrl>https://github.com/danielgerlag/workflow-core/blob/master/LICENSE.md</PackageLicenseUrl>
5+
<RepositoryType>git</RepositoryType>
6+
<RepositoryUrl>https://github.com/danielgerlag/workflow-core.git</RepositoryUrl>
7+
<Version>3.5.0</Version>
8+
<AssemblyVersion>3.5.0.0</AssemblyVersion>
9+
<FileVersion>3.5.0.0</FileVersion>
10+
<PackageIconUrl>https://github.com/danielgerlag/workflow-core/raw/master/src/logo.png</PackageIconUrl>
11+
<PackageVersion>3.5.0</PackageVersion>
12+
</PropertyGroup>
13+
</Project>

src/WorkflowCore.DSL/Models/DefinitionSource.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42

53
namespace WorkflowCore.Models.DefinitionStorage
64
{

src/WorkflowCore.DSL/Models/Envelope.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42

53
namespace WorkflowCore.Models.DefinitionStorage
64
{

src/WorkflowCore.DSL/Models/v1/MappingSourceV1.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42

53
namespace WorkflowCore.Models.DefinitionStorage.v1
64
{

src/WorkflowCore.DSL/Models/v1/StepSourceV1.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Dynamic;
4-
using System.Text;
54

65
namespace WorkflowCore.Models.DefinitionStorage.v1
76
{

src/WorkflowCore.DSL/ServiceCollectionExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.Extensions.DependencyInjection;
63
using WorkflowCore.Interface;
74
using WorkflowCore.Services.DefinitionStorage;
85

src/WorkflowCore.DSL/Services/DefinitionLoader.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
using Newtonsoft.Json;
2-
using System;
1+
using System;
32
using System.Collections;
43
using System.Collections.Generic;
54
using System.Linq;
65
using System.Linq.Dynamic.Core;
76
using System.Linq.Expressions;
87
using System.Reflection;
9-
using System.Text;
108
using Newtonsoft.Json.Linq;
119
using WorkflowCore.Interface;
1210
using WorkflowCore.Models;
1311
using WorkflowCore.Primitives;
14-
using WorkflowCore.Models.DefinitionStorage;
1512
using WorkflowCore.Models.DefinitionStorage.v1;
1613
using WorkflowCore.Exceptions;
1714

@@ -250,7 +247,7 @@ private void AttachOutputs(StepSourceV1 source, Type dataType, Type stepType, Wo
250247
private void AttachOutcomes(StepSourceV1 source, Type dataType, WorkflowStep step)
251248
{
252249
if (!string.IsNullOrEmpty(source.NextStepId))
253-
step.Outcomes.Add(new ValueOutcome() { ExternalNextStepId = $"{source.NextStepId}" });
250+
step.Outcomes.Add(new ValueOutcome { ExternalNextStepId = $"{source.NextStepId}" });
254251

255252
var dataParameter = Expression.Parameter(dataType, "data");
256253
var outcomeParameter = Expression.Parameter(typeof(object), "outcome");

src/WorkflowCore.DSL/WorkflowCore.DSL.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<Version>3.3.1</Version>
65
<Description>DSL extenstion for Workflow Core provding support for JSON and YAML workflow definitions.</Description>
76
<Authors>Daniel Gerlag</Authors>
87
<Company />
98
<Product>WorkflowCore</Product>
10-
<PackageProjectUrl>https://github.com/danielgerlag/workflow-core</PackageProjectUrl>
11-
<RepositoryUrl>https://github.com/danielgerlag/workflow-core.git</RepositoryUrl>
12-
<RepositoryType>git</RepositoryType>
139
</PropertyGroup>
1410

1511
<ItemGroup>

0 commit comments

Comments
 (0)