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