Skip to content

Commit 9ba9fbf

Browse files
committed
async steps
1 parent 13246fe commit 9ba9fbf

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

src/WorkflowCore/Interface/IStepBody.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace WorkflowCore.Interface
88
{
99
public interface IStepBody
1010
{
11-
ExecutionResult Run(IStepExecutionContext context);
11+
Task<ExecutionResult> RunAsync(IStepExecutionContext context);
1212
}
1313
}

src/WorkflowCore/Models/StepBody.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ namespace WorkflowCore.Models
88
{
99
public abstract class StepBody : IStepBody
1010
{
11-
11+
1212
public abstract ExecutionResult Run(IStepExecutionContext context);
1313

14+
public Task<ExecutionResult> RunAsync(IStepExecutionContext context)
15+
{
16+
return Task.FromResult(Run(context));
17+
}
18+
1419
protected ExecutionResult OutcomeResult(object value)
1520
{
1621
return new ExecutionResult()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using WorkflowCore.Interface;
6+
7+
namespace WorkflowCore.Models
8+
{
9+
public abstract class StepBodyAsync : IStepBody
10+
{
11+
public abstract Task<ExecutionResult> RunAsync(IStepExecutionContext context);
12+
13+
}
14+
}

src/WorkflowCore/Services/WorkflowExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public async Task<WorkflowExecutorResult> Execute(WorkflowInstance workflow, Wor
100100
continue;
101101
}
102102

103-
var result = body.Run(context);
103+
var result = await body.RunAsync(context);
104104

105105
ProcessOutputs(workflow, step, body);
106106
ProcessExecutionResult(workflow, def, pointer, step, result, wfResult);

test/WorkflowCore.UnitTests/Services/WorkflowExecutorFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public WorkflowExecutorFixture()
8080

8181
Registry = serviceProvider.GetService<IWorkflowRegistry>();
8282

83-
Subject = new WorkflowExecutor(Host, Registry, serviceProvider, new DateTimeProvider(), loggerFactory);
83+
Subject = new WorkflowExecutor(Registry, serviceProvider, new DateTimeProvider(), loggerFactory);
8484
}
8585

8686
[Fact]

0 commit comments

Comments
 (0)