| | | 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 | | /// A simple implementation that queues the specified request for delivering stimuli on a non-durable background worker. |
| | | 13 | | /// </summary> |
| | 6 | 14 | | public class BackgroundStimulusDispatcher(ICommandSender commandSender, ITenantAccessor tenantAccessor) : IStimulusDispa |
| | | 15 | | { |
| | | 16 | | /// <inheritdoc /> |
| | | 17 | | public async Task<DispatchStimulusResponse> SendAsync(DispatchStimulusRequest request, CancellationToken cancellatio |
| | | 18 | | { |
| | 3 | 19 | | var command = new DispatchStimulusCommand(request); |
| | 3 | 20 | | await commandSender.SendAsync(command, CommandStrategy.Background, CreateHeaders(), cancellationToken); |
| | 3 | 21 | | return DispatchStimulusResponse.Empty; |
| | 3 | 22 | | } |
| | | 23 | | |
| | | 24 | | private IDictionary<object, object> CreateHeaders() |
| | | 25 | | { |
| | 3 | 26 | | return TenantHeaders.CreateHeaders(tenantAccessor.Tenant?.Id); |
| | | 27 | | } |
| | | 28 | | } |