2023-03-03 21:47:23 +00:00
|
|
|
using Elsa.Workflows.Runtime.Contracts;
|
2023-01-04 19:36:38 +00:00
|
|
|
using Elsa.Workflows.Runtime.Notifications;
|
2023-03-03 21:47:23 +00:00
|
|
|
using IEventPublisher = Elsa.Mediator.Contracts.IEventPublisher;
|
2023-01-04 19:36:38 +00:00
|
|
|
|
2023-03-03 21:47:23 +00:00
|
|
|
namespace Elsa.Workflows.Runtime.Services;
|
2023-01-04 19:36:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Relies on the <see cref="IEventPublisher"/> to synchronously publish the received request as a domain event.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SynchronousTaskDispatcher : ITaskDispatcher
|
|
|
|
|
{
|
|
|
|
|
private readonly IEventPublisher _eventPublisher;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public SynchronousTaskDispatcher(IEventPublisher eventPublisher) => _eventPublisher = eventPublisher;
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public async Task DispatchAsync(RunTaskRequest request, CancellationToken cancellationToken = default) => await _eventPublisher.PublishAsync(request, cancellationToken);
|
|
|
|
|
}
|