< Summary

Information
Class: Elsa.Scheduling.ShellFeatures.SchedulingFeature
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/ShellFeatures/SchedulingFeature.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 28
Coverable lines: 28
Total lines: 71
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_WorkflowScheduler()100%210%
get_CronParser()100%210%
ConfigureServices(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/ShellFeatures/SchedulingFeature.cs

#LineLine coverage
 1using CShells.Features;
 2using Elsa.Common.Multitenancy;
 3using Elsa.Common.ShellFeatures;
 4using Elsa.Extensions;
 5using Elsa.Workflows.Options;
 6using Elsa.Scheduling.Bookmarks;
 7using Elsa.Scheduling.Handlers;
 8using Elsa.Scheduling.Options;
 9using Elsa.Scheduling.Services;
 10using Elsa.Scheduling.StartupTasks;
 11using Elsa.Scheduling.TriggerPayloadValidators;
 12using Elsa.Workflows.Management.Extensions;
 13using JetBrains.Annotations;
 14using Microsoft.Extensions.DependencyInjection;
 15using Elsa.Common.Serialization;
 16using Elsa.Platform.PackageManifest.Generator.Hints;
 17
 18namespace Elsa.Scheduling.ShellFeatures;
 19
 20/// <summary>
 21/// Provides scheduling features to the system.
 22/// </summary>
 23[ManifestFeatureCategory("Scheduling")]
 24[ManifestFeatureCategory("Workflows")]
 25[ShellFeature(
 26    DisplayName = "Scheduling",
 27    Description = "Provides scheduling capabilities for workflows including cron and delay-based triggers",
 28    DependsOn = [typeof(SystemClockFeature)])]
 29[UsedImplicitly]
 30public class SchedulingFeature : IShellFeature
 31{
 32    /// <summary>
 33    /// Gets or sets the trigger scheduler factory.
 34    /// </summary>
 035    public Func<IServiceProvider, IWorkflowScheduler> WorkflowScheduler { get; set; } = sp => sp.GetRequiredService<Defa
 36
 37    /// <summary>
 38    /// Gets or sets the CRON parser factory.
 39    /// </summary>
 040    public Func<IServiceProvider, ICronParser> CronParser { get; set; } = sp => sp.GetRequiredService<CronosCronParser>(
 41
 42    public void ConfigureServices(IServiceCollection services)
 43    {
 044        services
 045            .AddSingleton<UpdateTenantSchedules>()
 046            .AddSingleton<ITenantDeletedEvent>(sp => sp.GetRequiredService<UpdateTenantSchedules>())
 047            .AddSingleton<IScheduler, LocalScheduler>()
 048            .AddSingleton<PastDueScheduleStaggerer>()
 049            .AddSingleton<CronosCronParser>()
 050            .AddSingleton(CronParser)
 051            .AddScoped<ITriggerScheduler, DefaultTriggerScheduler>()
 052            .AddScoped<IBookmarkScheduler, DefaultBookmarkScheduler>()
 053            .AddScoped<DefaultWorkflowScheduler>()
 054            .AddScoped(WorkflowScheduler)
 055            .AddStartupTask<CreateSchedulesStartupTask>()
 056            .AddHandlersFrom<ScheduleWorkflows>()
 057            .AddTriggerPayloadValidator<CronTriggerPayloadValidator, CronTriggerPayload>()
 058            .AddActivitiesFrom<SchedulingFeature>();
 59
 060        services.Configure<SchedulingOptions>(_ => { });
 061        services.Configure<SerializationTypeOptions>(options =>
 062        {
 063            options.AddTypeAlias<CronBookmarkPayload>();
 064            options.AddTypeAlias<CronTriggerPayload>();
 065            options.AddTypeAlias<DelayPayload>();
 066            options.AddTypeAlias<StartAtPayload>();
 067            options.AddTypeAlias<TimerBookmarkPayload>();
 068            options.AddTypeAlias<TimerTriggerPayload>();
 069        });
 070    }
 71}