* Avoid null endpoint DTO metadata in tests * Enforce console logs hub read permission * Remove unused console logs hub import * Support mapped endpoint metadata in auth tests * Reduce console log capture throughput impact * Address Copilot console logs review * Refactor task scheduling to support tenant-level background work and enhance logging functionality. * Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage. * Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly. * Add Ansi SGR parser for console logs and associated unit tests * Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support. * Address console logs code quality feedback * Address PR review feedback * Preserve console logs extension points * Stabilize console logs host lifecycle * Address final automated review comments * Tighten console log capture shutdown * Address console log review feedback * Address follow-up review feedback * Cover final review feedback * Avoid recursive console provider initialization * Guard console host lease shutdown * Preserve console log scope and provider lifetime * Correlate console log scope fallback * Tighten console scope correlation * Expose host services during provider construction * Redact ANSI-normalized console lines
51 lines
2.1 KiB
C#
51 lines
2.1 KiB
C#
using Elsa.Common;
|
|
using Elsa.Common.Multitenancy;
|
|
using Elsa.Workflows.Runtime;
|
|
using Elsa.Workflows.Runtime.Filters;
|
|
using Elsa.Workflows.Runtime.Tasks;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Elsa.Scheduling.StartupTasks;
|
|
|
|
/// <summary>
|
|
/// Enqueues schedule creation when using the default scheduler, which doesn't have its own persistence layer like Quartz or Hangfire.
|
|
/// </summary>
|
|
[TaskDependency(typeof(PopulateRegistriesStartupTask))]
|
|
public class CreateSchedulesStartupTask(IServiceProvider serviceProvider) : IStartupTask
|
|
{
|
|
public async Task ExecuteAsync(CancellationToken cancellationToken)
|
|
{
|
|
var workQueue = serviceProvider.GetService<ITenantBackgroundWorkQueue>();
|
|
|
|
if (workQueue != null)
|
|
await workQueue.EnqueueAsync(CreateSchedulesAsync, cancellationToken);
|
|
else
|
|
await CreateSchedulesAsync(serviceProvider, cancellationToken);
|
|
}
|
|
|
|
private static async Task CreateSchedulesAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken)
|
|
{
|
|
var triggerStore = serviceProvider.GetRequiredService<ITriggerStore>();
|
|
var bookmarkStore = serviceProvider.GetRequiredService<IBookmarkStore>();
|
|
var triggerScheduler = serviceProvider.GetRequiredService<ITriggerScheduler>();
|
|
var bookmarkScheduler = serviceProvider.GetRequiredService<IBookmarkScheduler>();
|
|
var stimulusNames = new[]
|
|
{
|
|
SchedulingStimulusNames.Cron, SchedulingStimulusNames.Timer, SchedulingStimulusNames.StartAt, SchedulingStimulusNames.Delay,
|
|
};
|
|
var triggerFilter = new TriggerFilter
|
|
{
|
|
Names = stimulusNames
|
|
};
|
|
var bookmarkFilter = new BookmarkFilter
|
|
{
|
|
Names = stimulusNames
|
|
};
|
|
var triggers = (await triggerStore.FindManyAsync(triggerFilter, cancellationToken)).ToList();
|
|
var bookmarks = (await bookmarkStore.FindManyAsync(bookmarkFilter, cancellationToken)).ToList();
|
|
|
|
await triggerScheduler.ScheduleAsync(triggers, cancellationToken);
|
|
await bookmarkScheduler.ScheduleAsync(bookmarks, cancellationToken);
|
|
}
|
|
}
|