using System.Threading.Channels;
using Elsa.Workflows.Runtime.Contracts;
using Elsa.Workflows.Runtime.Models;
namespace Elsa.Workflows.Runtime.Services;
///
/// Invokes activities from a background worker within the context of its workflow instance using a local background worker.
///
public class LocalBackgroundActivityScheduler : IBackgroundActivityScheduler
{
private readonly Channel _channel;
///
/// Initializes a new instance of the class.
///
/// The channel to write to.
public LocalBackgroundActivityScheduler(Channel channel)
{
_channel = channel;
}
///
public async Task ScheduleAsync(ScheduledBackgroundActivity scheduledBackgroundActivity, CancellationToken cancellationToken = default)
{
await _channel.Writer.WriteAsync(scheduledBackgroundActivity, cancellationToken);
return "";
}
}