Skip to content

Commit 13e964f

Browse files
authored
Merge branch 'master' into transaction
2 parents 3348dca + 667abca commit 13e964f

File tree

62 files changed

+864
-488
lines changed

Some content is hidden

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

62 files changed

+864
-488
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup .NET
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 3.1.301
19+
dotnet-version: 5.0.*
2020
- name: Restore dependencies
2121
run: dotnet restore
2222
- name: Build

ReleaseNotes/3.4.0.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,27 @@ public class MetricsMiddleware : IWorkflowMiddleware
3838
switch (workflow.Status)
3939
{
4040
case WorkflowStatus.Complete:
41-
if (_suspendedWorkflows.TryRemove(workflow.Id))
42-
{
43-
_suspended.Dec();
44-
}
41+
TryDecrementSuspended(workflow);
4542
_completed.Inc();
4643
break;
4744
case WorkflowStatus.Suspended:
45+
_suspendedWorkflows.Add(workflow.Id);
4846
_suspended.Inc();
4947
break;
48+
default:
49+
TryDecrementSuspended(workflow);
50+
break;
5051
}
5152

5253
return next();
5354
}
55+
56+
private void TryDecrementSuspended(WorkflowInstance workflow)
57+
{
58+
if (_suspendedWorkflows.TryRemove(workflow.Id))
59+
{
60+
_suspended.Dec();
61+
}
62+
}
5463
}
5564
```

WorkflowCore.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF47161E-E39
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F6AC9AEB-24EF-475A-B190-AA4D9E01270A}"
99
ProjectSection(SolutionItems) = preProject
10-
readme.md = readme.md
10+
README.md = README.md
1111
EndProjectSection
1212
EndProject
1313
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{5080DB09-CBE8-4C45-9957-C3BB7651755E}"

docs/getting-started.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public class MyDataClass
142142
{
143143
public int Value1 { get; set; }
144144
public int Value2 { get; set; }
145-
public int Value3 { get; set; }
145+
public int Answer { get; set; }
146146
}
147147

148148
//Our workflow definition with strongly typed internal data and mapped inputs & outputs
@@ -154,9 +154,9 @@ public class PassingDataWorkflow : IWorkflow<MyDataClass>
154154
.StartWith<AddNumbers>()
155155
.Input(step => step.Input1, data => data.Value1)
156156
.Input(step => step.Input2, data => data.Value2)
157-
.Output(data => data.Value3, step => step.Output)
157+
.Output(data => data.Answer, step => step.Output)
158158
.Then<CustomMessage>()
159-
.Input(step => step.Message, data => "The answer is " + data.Value3.ToString());
159+
.Input(step => step.Message, data => "The answer is " + data.Answer.ToString());
160160
}
161161
...
162162
}
@@ -175,8 +175,8 @@ or in jSON format
175175
"StepType": "MyApp.AddNumbers, MyApp",
176176
"NextStepId": "ShowResult",
177177
"Inputs": {
178-
"Value1": "data.Value1",
179-
"Value2": "data.Value2"
178+
"Input1": "data.Value1",
179+
"Input2": "data.Value2"
180180
},
181181
"Outputs": {
182182
"Answer": "step.Output"
@@ -186,7 +186,7 @@ or in jSON format
186186
"Id": "ShowResult",
187187
"StepType": "MyApp.CustomMessage, MyApp",
188188
"Inputs": {
189-
"Message": "\"The answer is \" + data.Value1"
189+
"Message": "\"The answer is \" + data.Answer"
190190
}
191191
}
192192
]
@@ -203,14 +203,14 @@ Steps:
203203
StepType: MyApp.AddNumbers, MyApp
204204
NextStepId: ShowResult
205205
Inputs:
206-
Value1: data.Value1
207-
Value2: data.Value2
206+
Input1: data.Value1
207+
Input2: data.Value2
208208
Outputs:
209209
Answer: step.Output
210210
- Id: ShowResult
211211
StepType: MyApp.CustomMessage, MyApp
212212
Inputs:
213-
Message: '"The answer is " + data.Value1'
213+
Message: '"The answer is " + data.Answer'
214214
```
215215
216216

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.3</Version>
8+
<AssemblyVersion>3.5.4.0</AssemblyVersion>
9+
<FileVersion>3.5.4.0</FileVersion>
10+
<PackageIconUrl>https://github.com/danielgerlag/workflow-core/raw/master/src/logo.png</PackageIconUrl>
11+
<PackageVersion>3.5.4</PackageVersion>
12+
</PropertyGroup>
13+
</Project>

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>

src/WorkflowCore/Interface/IDistributedLockProvider.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ namespace WorkflowCore.Interface
99
/// </remarks>
1010
public interface IDistributedLockProvider
1111
{
12+
/// <summary>
13+
/// Acquire a lock on the specified resource.
14+
/// </summary>
15+
/// <param name="Id">Resource ID to lock.</param>
16+
/// <param name="cancellationToken"></param>
17+
/// <returns>`true`, if the lock was acquired.</returns>
1218
Task<bool> AcquireLock(string Id, CancellationToken cancellationToken);
1319

1420
Task ReleaseLock(string Id);
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Threading;
34
using System.Threading.Tasks;
45
using WorkflowCore.Models;
56

67
namespace WorkflowCore.Interface
78
{
89
public interface IEventRepository
910
{
10-
Task<string> CreateEvent(Event newEvent);
11+
Task<string> CreateEvent(Event newEvent, CancellationToken cancellationToken = default);
1112

12-
Task<Event> GetEvent(string id);
13+
Task<Event> GetEvent(string id, CancellationToken cancellationToken = default);
1314

14-
Task<IEnumerable<string>> GetRunnableEvents(DateTime asAt);
15+
Task<IEnumerable<string>> GetRunnableEvents(DateTime asAt, CancellationToken cancellationToken = default);
1516

16-
Task<IEnumerable<string>> GetEvents(string eventName, string eventKey, DateTime asOf);
17+
Task<IEnumerable<string>> GetEvents(string eventName, string eventKey, DateTime asOf, CancellationToken cancellationToken = default);
1718

18-
Task MarkEventProcessed(string id);
19+
Task MarkEventProcessed(string id, CancellationToken cancellationToken = default);
1920

20-
Task MarkEventUnprocessed(string id);
21+
Task MarkEventUnprocessed(string id, CancellationToken cancellationToken = default);
2122

2223
}
2324
}

src/WorkflowCore/Interface/Persistence/IPersistenceProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Threading;
34
using System.Threading.Tasks;
45
using WorkflowCore.Models;
56

@@ -8,7 +9,7 @@ namespace WorkflowCore.Interface
89
public interface IPersistenceProvider : IWorkflowRepository, ISubscriptionRepository, IEventRepository
910
{
1011

11-
Task PersistErrors(IEnumerable<ExecutionError> errors);
12+
Task PersistErrors(IEnumerable<ExecutionError> errors, CancellationToken cancellationToken = default);
1213

1314
void EnsureStoreExists();
1415

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Threading;
34
using System.Threading.Tasks;
45
using WorkflowCore.Models;
56

67
namespace WorkflowCore.Interface
78
{
89
public interface ISubscriptionRepository
910
{
10-
Task<string> CreateEventSubscription(EventSubscription subscription);
11+
Task<string> CreateEventSubscription(EventSubscription subscription, CancellationToken cancellationToken = default);
1112

12-
Task<IEnumerable<EventSubscription>> GetSubscriptions(string eventName, string eventKey, DateTime asOf);
13+
Task<IEnumerable<EventSubscription>> GetSubscriptions(string eventName, string eventKey, DateTime asOf, CancellationToken cancellationToken = default);
1314

14-
Task TerminateSubscription(string eventSubscriptionId);
15+
Task TerminateSubscription(string eventSubscriptionId, CancellationToken cancellationToken = default);
1516

16-
Task<EventSubscription> GetSubscription(string eventSubscriptionId);
17+
Task<EventSubscription> GetSubscription(string eventSubscriptionId, CancellationToken cancellationToken = default);
1718

18-
Task<EventSubscription> GetFirstOpenSubscription(string eventName, string eventKey, DateTime asOf);
19+
Task<EventSubscription> GetFirstOpenSubscription(string eventName, string eventKey, DateTime asOf, CancellationToken cancellationToken = default);
1920

20-
Task<bool> SetSubscriptionToken(string eventSubscriptionId, string token, string workerId, DateTime expiry);
21+
Task<bool> SetSubscriptionToken(string eventSubscriptionId, string token, string workerId, DateTime expiry, CancellationToken cancellationToken = default);
2122

22-
Task ClearSubscriptionToken(string eventSubscriptionId, string token);
23+
Task ClearSubscriptionToken(string eventSubscriptionId, string token, CancellationToken cancellationToken = default);
2324

2425
}
2526
}

0 commit comments

Comments
 (0)