elsa-core/src/modules/Elsa.Jobs/Implementations/LocalJobQueue.cs
2022-11-13 12:45:34 +01:00

22 lines
627 B
C#

using System.Threading.Channels;
using Elsa.Jobs.Services;
namespace Elsa.Jobs.Implementations;
/// <summary>
/// Represents a local, in-memory queue of jobs that will be processed in-process.
/// </summary>
public class LocalJobQueue : IJobQueue
{
private readonly ChannelWriter<IJob> _channelWriter;
public LocalJobQueue(ChannelWriter<IJob> channelWriter)
{
_channelWriter = channelWriter;
}
public async Task SubmitJobAsync(IJob job, string? queueName = default, CancellationToken cancellationToken = default)
{
await _channelWriter.WriteAsync(job, cancellationToken);
}
}