< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Scheduling.ScheduledTask
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Scheduling/ScheduledTask.cs
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 62
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

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Name()100%11100%
get_Work()100%11100%
get_Cron()100%11100%
get_Interval()100%11100%
get_RunImmediately()100%11100%
get_TokenSource()100%11100%
get_LastRunAt()100%11100%
get_NextRunAt()100%11100%
get_Runner()100%11100%
get_AnchorAt()100%11100%
get_RunIteration()100%11100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Scheduling/ScheduledTask.cs

#LineLine coverage
 1using Cronos;
 2
 3namespace Kestrun.Scheduling;
 4
 5/// <summary>
 6/// Represents a scheduled task with its configuration and state.
 7/// This record is used to encapsulate the details of a scheduled task,
 8/// </summary>
 9/// <param name="Name">The name of the task.</param>
 10/// <param name="Work">The work to be performed by the task.</param>
 11/// <param name="Cron">The cron expression for the task.</param>
 12/// <param name="Interval">The interval for the task.</param>
 13/// <param name="RunImmediately">Whether to run the task immediately.</param>
 14/// <param name="TokenSource">The cancellation token source for the task.</param>
 2515internal sealed record ScheduledTask(
 4516    string Name,
 2117    Func<CancellationToken, Task> Work,
 1918    CronExpression? Cron,
 7019    TimeSpan? Interval,
 2420    bool RunImmediately,
 4821    CancellationTokenSource TokenSource
 2522)
 23{
 24    /// <summary>
 25    /// The last time this task was run, or null if it has not run yet.
 26    /// This is used to determine if the task has run at least once.
 27    /// </summary>
 6028    public DateTimeOffset? LastRunAt { get; set; }
 29
 30    /// <summary>
 31    ///  The next time this task is scheduled to run, based on the cron expression or interval.
 32    ///  If the task is not scheduled, this will be DateTimeOffset.MinValue.
 33    /// </summary>
 11934    public DateTimeOffset NextRunAt { get; set; }
 35
 36    /// <summary>
 37    /// Indicates whether the task is currently suspended.
 38    /// A suspended task will not run until resumed.
 39    /// </summary>
 40    public volatile bool IsSuspended;
 41
 42    /// <summary>
 43    /// The background runner task handling the scheduling loop. Used to allow
 44    /// graceful cancellation (tests assert no further executions after Cancel()).
 45    /// </summary>
 4846    public Task? Runner { get; set; }
 47
 48    /// <summary>
 49    /// Fixed anchor timestamp captured at schedule time for interval jobs to enable fixed-rate scheduling.
 50    /// </summary>
 4851    public DateTimeOffset AnchorAt { get; init; } = DateTimeOffset.UtcNow;
 52
 53    /// <summary>
 54    /// Number of successful executions completed (for interval jobs) to compute deterministic next slot.
 55    /// </summary>
 7756    public int RunIteration { get; set; }
 57
 58    /// <summary>
 59    /// True when the scheduling loop has exited.
 60    /// </summary>
 61    public volatile bool IsCompleted;
 62}