< 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: 26
Coverable lines: 26
Total lines: 65
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.Services;
 9using Elsa.Scheduling.StartupTasks;
 10using Elsa.Scheduling.TriggerPayloadValidators;
 11using Elsa.Workflows.Management.Extensions;
 12using JetBrains.Annotations;
 13using Microsoft.Extensions.DependencyInjection;
 14using Elsa.Common.Serialization;
 15
 16namespace Elsa.Scheduling.ShellFeatures;
 17
 18/// <summary>
 19/// Provides scheduling features to the system.
 20/// </summary>
 21[ShellFeature(
 22    DisplayName = "Scheduling",
 23    Description = "Provides scheduling capabilities for workflows including cron and delay-based triggers",
 24    DependsOn = [typeof(SystemClockFeature)])]
 25[UsedImplicitly]
 26public class SchedulingFeature : IShellFeature
 27{
 28    /// <summary>
 29    /// Gets or sets the trigger scheduler factory.
 30    /// </summary>
 031    public Func<IServiceProvider, IWorkflowScheduler> WorkflowScheduler { get; set; } = sp => sp.GetRequiredService<Defa
 32
 33    /// <summary>
 34    /// Gets or sets the CRON parser factory.
 35    /// </summary>
 036    public Func<IServiceProvider, ICronParser> CronParser { get; set; } = sp => sp.GetRequiredService<CronosCronParser>(
 37
 38    public void ConfigureServices(IServiceCollection services)
 39    {
 040        services
 041            .AddSingleton<UpdateTenantSchedules>()
 042            .AddSingleton<ITenantDeletedEvent>(sp => sp.GetRequiredService<UpdateTenantSchedules>())
 043            .AddSingleton<IScheduler, LocalScheduler>()
 044            .AddSingleton<CronosCronParser>()
 045            .AddSingleton(CronParser)
 046            .AddScoped<ITriggerScheduler, DefaultTriggerScheduler>()
 047            .AddScoped<IBookmarkScheduler, DefaultBookmarkScheduler>()
 048            .AddScoped<DefaultWorkflowScheduler>()
 049            .AddScoped(WorkflowScheduler)
 050            .AddStartupTask<CreateSchedulesStartupTask>()
 051            .AddHandlersFrom<ScheduleWorkflows>()
 052            .AddTriggerPayloadValidator<CronTriggerPayloadValidator, CronTriggerPayload>()
 053            .AddActivitiesFrom<SchedulingFeature>();
 54
 055        services.Configure<SerializationTypeOptions>(options =>
 056        {
 057            options.AddTypeAlias<CronBookmarkPayload>();
 058            options.AddTypeAlias<CronTriggerPayload>();
 059            options.AddTypeAlias<DelayPayload>();
 060            options.AddTypeAlias<StartAtPayload>();
 061            options.AddTypeAlias<TimerBookmarkPayload>();
 062            options.AddTypeAlias<TimerTriggerPayload>();
 063        });
 064    }
 65}