-
Notifications
You must be signed in to change notification settings - Fork 54
/
CancelWorkflowInstanceCommand.cs
39 lines (35 loc) · 1.46 KB
/
CancelWorkflowInstanceCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Threading.Tasks;
using GatewayProtocol;
using Zeebe.Client.Api.Commands;
using Zeebe.Client.Api.Misc;
using Zeebe.Client.Api.Responses;
using CancelWorkflowInstanceResponse = Zeebe.Client.Impl.Responses.CancelWorkflowInstanceResponse;
namespace Zeebe.Client.Impl.Commands
{
public class CancelWorkflowInstanceCommand : ICancelWorkflowInstanceCommandStep1
{
private readonly CancelWorkflowInstanceRequest request;
private readonly Gateway.GatewayClient client;
private readonly IAsyncRetryStrategy asyncRetryStrategy;
public CancelWorkflowInstanceCommand(Gateway.GatewayClient client, IAsyncRetryStrategy asyncRetryStrategy, long workflowInstanceKey)
{
request = new CancelWorkflowInstanceRequest
{
WorkflowInstanceKey = workflowInstanceKey
};
this.client = client;
this.asyncRetryStrategy = asyncRetryStrategy;
}
public async Task<ICancelWorkflowInstanceResponse> Send(TimeSpan? timeout = null)
{
var asyncReply = client.CancelWorkflowInstanceAsync(request, deadline: timeout?.FromUtcNow());
await asyncReply.ResponseAsync;
return new CancelWorkflowInstanceResponse();
}
public async Task<ICancelWorkflowInstanceResponse> SendWithRetry(TimeSpan? timespan = null)
{
return await asyncRetryStrategy.DoWithRetry(() => Send(timespan));
}
}
}