| | | 1 | | using Elsa.Common.Multitenancy; |
| | | 2 | | using Elsa.Mediator; |
| | | 3 | | using Elsa.Mediator.Contracts; |
| | | 4 | | using Elsa.Tenants.Mediator; |
| | | 5 | | using Elsa.Workflows.Runtime.Commands; |
| | | 6 | | using Elsa.Workflows.Runtime.Requests; |
| | | 7 | | using Elsa.Workflows.Runtime.Responses; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Workflows.Runtime; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Dispatches workflow cancellation requests to a local background worker. |
| | | 13 | | /// </summary> |
| | 12 | 14 | | public class BackgroundWorkflowCancellationDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IW |
| | | 15 | | { |
| | | 16 | | /// <inheritdoc /> |
| | | 17 | | public async Task<DispatchCancelWorkflowsResponse> DispatchAsync(DispatchCancelWorkflowRequest request, Cancellation |
| | | 18 | | { |
| | 5 | 19 | | var command = new CancelWorkflowsCommand(request); |
| | 5 | 20 | | await commandSender.SendAsync(command, CommandStrategy.Background, CreateHeaders(), cancellationToken); |
| | 5 | 21 | | return new(); |
| | 5 | 22 | | } |
| | | 23 | | |
| | | 24 | | private IDictionary<object, object> CreateHeaders() |
| | | 25 | | { |
| | 5 | 26 | | return TenantHeaders.CreateHeaders(tenantAccessor.Tenant?.Id); |
| | | 27 | | } |
| | | 28 | | } |