< Summary

Information
Class: Elsa.Scheduling.Services.DefaultWorkflowScheduler
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Services/DefaultWorkflowScheduler.cs
Line coverage
76%
Covered lines: 19
Uncovered lines: 6
Coverable lines: 25
Total lines: 62
Line coverage: 76%
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%
ScheduleAtAsync()100%210%
ScheduleAtAsync()100%11100%
ScheduleRecurringAsync()100%11100%
ScheduleRecurringAsync()100%210%
ScheduleCronAsync()100%11100%
ScheduleCronAsync()100%11100%
UnscheduleAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Services/DefaultWorkflowScheduler.cs

#LineLine coverage
 1using Elsa.Scheduling.Schedules;
 2using Elsa.Scheduling.Tasks;
 3
 4namespace Elsa.Scheduling.Services;
 5
 6/// <summary>
 7/// A default implementation of <see cref="IWorkflowScheduler"/> that uses the <see cref="LocalScheduler"/>.
 8/// </summary>
 4539public class DefaultWorkflowScheduler(IScheduler scheduler) : IWorkflowScheduler
 10{
 11    /// <inheritdoc />
 12    public async ValueTask ScheduleAtAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, DateTimeOffset a
 13    {
 014        await scheduler.ScheduleAsync(taskName, new RunWorkflowTask(request), new SpecificInstantSchedule(at), cancellat
 015    }
 16
 17    /// <inheritdoc />
 18    public async ValueTask ScheduleAtAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, DateTimeOff
 19    {
 1720        var task = new ResumeWorkflowTask(request);
 1721        var schedule = new SpecificInstantSchedule(at);
 1722        await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken);
 1723    }
 24
 25    /// <inheritdoc />
 26    public async ValueTask ScheduleRecurringAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, DateTimeO
 27    {
 228        var task = new RunWorkflowTask(request);
 229        var schedule = new RecurringSchedule(startAt, interval);
 230        await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken);
 231    }
 32
 33    /// <inheritdoc />
 34    public async ValueTask ScheduleRecurringAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, Date
 35    {
 036        var task = new ResumeWorkflowTask(request);
 037        var schedule = new RecurringSchedule(startAt, interval);
 038        await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken);
 039    }
 40
 41    /// <inheritdoc />
 42    public async ValueTask ScheduleCronAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, string cronExp
 43    {
 144        var task = new RunWorkflowTask(request);
 145        var schedule = new CronSchedule(cronExpression);
 146        await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken);
 147    }
 48
 49    /// <inheritdoc />
 50    public async ValueTask ScheduleCronAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, string cr
 51    {
 152        var task = new ResumeWorkflowTask(request);
 153        var schedule = new CronSchedule(cronExpression);
 154        await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken);
 155    }
 56
 57    /// <inheritdoc />
 58    public async ValueTask UnscheduleAsync(string taskName, CancellationToken cancellationToken = default)
 59    {
 3360        await scheduler.ClearScheduleAsync(taskName, cancellationToken);
 3361    }
 62}