< Summary

Information
Class: Elsa.Scheduling.Features.SchedulingFeature
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Features/SchedulingFeature.cs
Line coverage
100%
Covered lines: 33
Uncovered lines: 0
Coverable lines: 33
Total lines: 74
Line coverage: 100%
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
.ctor(...)100%11100%
get_WorkflowScheduler()100%11100%
get_CronParser()100%11100%
Apply()100%11100%

File(s)

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

#LineLine coverage
 1using Elsa.Common.Features;
 2using Elsa.Common.Multitenancy;
 3using Elsa.Extensions;
 4using Elsa.Features.Abstractions;
 5using Elsa.Features.Attributes;
 6using Elsa.Features.Services;
 7using Elsa.Scheduling.Bookmarks;
 8using Elsa.Scheduling.Handlers;
 9using Elsa.Scheduling.Services;
 10using Elsa.Scheduling.StartupTasks;
 11using Elsa.Scheduling.TriggerPayloadValidators;
 12using Elsa.Workflows.Management.Features;
 13using Elsa.Workflows.Options;
 14using Microsoft.Extensions.DependencyInjection;
 15using Elsa.Common.Serialization;
 16
 17namespace Elsa.Scheduling.Features;
 18
 19/// <summary>
 20/// Provides scheduling features to the system.
 21/// </summary>
 22[DependsOn(typeof(SystemClockFeature))]
 23public class SchedulingFeature : FeatureBase
 24{
 25    /// <inheritdoc />
 21326    public SchedulingFeature(IModule module) : base(module)
 27    {
 21328    }
 29
 30    /// <summary>
 31    /// Gets or sets the trigger scheduler.
 32    /// </summary>
 105033    public Func<IServiceProvider, IWorkflowScheduler> WorkflowScheduler { get; set; } = sp => sp.GetRequiredService<Defa
 34
 35    /// <summary>
 36    /// Gets or sets the CRON parser.
 37    /// </summary>
 42938    public Func<IServiceProvider, ICronParser> CronParser { get; set; } = sp => sp.GetRequiredService<CronosCronParser>(
 39
 40    /// <inheritdoc />
 41    public override void Apply()
 42    {
 21343        Services
 21344            .AddSingleton<UpdateTenantSchedules>()
 7245            .AddSingleton<ITenantDeletedEvent>(sp => sp.GetRequiredService<UpdateTenantSchedules>())
 21346            .AddSingleton<IScheduler, LocalScheduler>()
 21347            .AddSingleton<CronosCronParser>()
 21348            .AddSingleton(CronParser)
 21349            .AddScoped<ITriggerScheduler, DefaultTriggerScheduler>()
 21350            .AddScoped<IBookmarkScheduler, DefaultBookmarkScheduler>()
 21351            .AddScoped<DefaultWorkflowScheduler>()
 21352            .AddScoped(WorkflowScheduler)
 21353            .AddStartupTask<CreateSchedulesStartupTask>()
 21354            .AddHandlersFrom<ScheduleWorkflows>()
 21355
 21356            //Trigger payload validators.
 21357            .AddTriggerPayloadValidator<CronTriggerPayloadValidator, CronTriggerPayload>()
 21358
 21359            // Graceful shutdown: register scheduled-trigger ingress for diagnostic visibility (FR-006).
 21360            .AddSingleton<Elsa.Workflows.Runtime.IIngressSource, Elsa.Scheduling.IngressSources.ScheduledTriggerIngressS
 61
 21362        Services.Configure<SerializationTypeOptions>(options =>
 21363        {
 19364            options.RegisterTypeAlias(typeof(CronBookmarkPayload), nameof(CronBookmarkPayload));
 19365            options.RegisterTypeAlias(typeof(CronTriggerPayload), nameof(CronTriggerPayload));
 19366            options.RegisterTypeAlias(typeof(DelayPayload), nameof(DelayPayload));
 19367            options.RegisterTypeAlias(typeof(StartAtPayload), nameof(StartAtPayload));
 19368            options.RegisterTypeAlias(typeof(TimerBookmarkPayload), nameof(TimerBookmarkPayload));
 19369            options.RegisterTypeAlias(typeof(TimerTriggerPayload), nameof(TimerTriggerPayload));
 40670        });
 71
 42672        Module.Configure<WorkflowManagementFeature>(management => management.AddActivitiesFrom<SchedulingFeature>());
 21373    }
 74}