< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.RuntimeAdmin.IngressSourceStateDto
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/RuntimeAdmin/Models.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 105
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_Name()100%210%
get_State()100%210%
get_LastError()100%210%
get_LastTransitionAt()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/RuntimeAdmin/Models.cs

#LineLine coverage
 1using Elsa.Workflows.Runtime;
 2
 3namespace Elsa.Workflows.Api.Endpoints.RuntimeAdmin;
 4
 5/// <summary>Body for the pause endpoint. The reason is a free-form human-readable string captured on the audit event.</
 6public class PauseRequest
 7{
 8    public string? Reason { get; set; }
 9}
 10
 11/// <summary>Body for the resume endpoint.</summary>
 12[Obsolete("Use FastEndpoints.EmptyRequest instead.")]
 13public class ResumeRequest
 14{
 15}
 16
 17/// <summary>Body for the operator-force drain endpoint.</summary>
 18public class ForceDrainRequest
 19{
 20    public string? Reason { get; set; }
 21}
 22
 23/// <summary>Composite quiescence state surfaced by status / pause / resume responses.</summary>
 24public class QuiescenceStateDto
 25{
 26    public string Reason { get; set; } = null!;
 27    public bool IsAcceptingNewWork { get; set; }
 28    public DateTimeOffset? PausedAt { get; set; }
 29    public DateTimeOffset? DrainStartedAt { get; set; }
 30    public string? PauseReasonText { get; set; }
 31    public string? PauseRequestedBy { get; set; }
 32    public string GenerationId { get; set; } = null!;
 33}
 34
 35/// <summary>Per-ingress-source state surfaced by status / pause / resume responses.</summary>
 36public class IngressSourceStateDto
 37{
 038    public string Name { get; set; } = null!;
 039    public string State { get; set; } = null!;
 040    public string? LastError { get; set; }
 041    public DateTimeOffset? LastTransitionAt { get; set; }
 42}
 43
 44/// <summary>Status / pause / resume response. Idempotent endpoints return the post-request state.</summary>
 45public class StatusResponse
 46{
 47    public QuiescenceStateDto State { get; set; } = null!;
 48    public List<IngressSourceStateDto> Sources { get; set; } = new();
 49    public int ActiveExecutionCycleCount { get; set; }
 50}
 51
 52/// <summary>Force-drain outcome surfaced by the force endpoint.</summary>
 53public class DrainOutcomeDto
 54{
 55    public string OverallResult { get; set; } = null!;
 56    public DateTimeOffset StartedAt { get; set; }
 57    public DateTimeOffset CompletedAt { get; set; }
 58    public TimeSpan PausePhaseDuration { get; set; }
 59    public TimeSpan WaitPhaseDuration { get; set; }
 60    public List<IngressSourceStateDto> Sources { get; set; } = new();
 61    public int ExecutionCyclesForceCancelledCount { get; set; }
 62    public List<string> ForceCancelledInstanceIds { get; set; } = new();
 63}
 64
 65/// <summary>Force-drain endpoint response.</summary>
 66public class ForceDrainResponse
 67{
 68    public DrainOutcomeDto Outcome { get; set; } = null!;
 69}
 70
 71/// <summary>Returned by resume/force endpoints when a drain is already in progress.</summary>
 72public class ConflictResponse
 73{
 74    public string Code { get; set; } = null!;
 75    public StatusResponse State { get; set; } = null!;
 76}
 77
 78internal static class StatusResponseFactory
 79{
 80    public static QuiescenceStateDto MapState(QuiescenceState state) => new()
 81    {
 82        Reason = state.Reason.ToString(),
 83        IsAcceptingNewWork = state.IsAcceptingNewWork,
 84        PausedAt = state.PausedAt,
 85        DrainStartedAt = state.DrainStartedAt,
 86        PauseReasonText = state.PauseReasonText,
 87        PauseRequestedBy = state.PauseRequestedBy,
 88        GenerationId = state.GenerationId,
 89    };
 90
 91    public static IngressSourceStateDto MapSource(IngressSourceSnapshot s) => new()
 92    {
 93        Name = s.Name,
 94        State = s.State.ToString(),
 95        LastError = s.LastError?.Message,
 96        LastTransitionAt = s.LastTransitionAt,
 97    };
 98
 99    public static StatusResponse Build(RuntimeAdminStatus status) => new()
 100    {
 101        State = MapState(status.State),
 102        Sources = status.Sources.Select(MapSource).ToList(),
 103        ActiveExecutionCycleCount = status.ActiveExecutionCycleCount,
 104    };
 105}