< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.RuntimeAdmin.StatusResponseFactory
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: 23
Coverable lines: 23
Total lines: 104
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
MapState(...)100%210%
MapSource(...)0%620%
Build(...)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. No fields today — kept as a class so the endpoint signature is uniform.</summ
 12public class ResumeRequest
 13{
 14}
 15
 16/// <summary>Body for the operator-force drain endpoint.</summary>
 17public class ForceDrainRequest
 18{
 19    public string? Reason { get; set; }
 20}
 21
 22/// <summary>Composite quiescence state surfaced by status / pause / resume responses.</summary>
 23public class QuiescenceStateDto
 24{
 25    public string Reason { get; set; } = null!;
 26    public bool IsAcceptingNewWork { get; set; }
 27    public DateTimeOffset? PausedAt { get; set; }
 28    public DateTimeOffset? DrainStartedAt { get; set; }
 29    public string? PauseReasonText { get; set; }
 30    public string? PauseRequestedBy { get; set; }
 31    public string GenerationId { get; set; } = null!;
 32}
 33
 34/// <summary>Per-ingress-source state surfaced by status / pause / resume responses.</summary>
 35public class IngressSourceStateDto
 36{
 37    public string Name { get; set; } = null!;
 38    public string State { get; set; } = null!;
 39    public string? LastError { get; set; }
 40    public DateTimeOffset? LastTransitionAt { get; set; }
 41}
 42
 43/// <summary>Status / pause / resume response. Idempotent endpoints return the post-request state.</summary>
 44public class StatusResponse
 45{
 46    public QuiescenceStateDto State { get; set; } = null!;
 47    public List<IngressSourceStateDto> Sources { get; set; } = new();
 48    public int ActiveExecutionCycleCount { get; set; }
 49}
 50
 51/// <summary>Force-drain outcome surfaced by the force endpoint.</summary>
 52public class DrainOutcomeDto
 53{
 54    public string OverallResult { get; set; } = null!;
 55    public DateTimeOffset StartedAt { get; set; }
 56    public DateTimeOffset CompletedAt { get; set; }
 57    public TimeSpan PausePhaseDuration { get; set; }
 58    public TimeSpan WaitPhaseDuration { get; set; }
 59    public List<IngressSourceStateDto> Sources { get; set; } = new();
 60    public int ExecutionCyclesForceCancelledCount { get; set; }
 61    public List<string> ForceCancelledInstanceIds { get; set; } = new();
 62}
 63
 64/// <summary>Force-drain endpoint response.</summary>
 65public class ForceDrainResponse
 66{
 67    public DrainOutcomeDto Outcome { get; set; } = null!;
 68}
 69
 70/// <summary>Returned by resume/force endpoints when a drain is already in progress.</summary>
 71public class ConflictResponse
 72{
 73    public string Code { get; set; } = null!;
 74    public StatusResponse State { get; set; } = null!;
 75}
 76
 77internal static class StatusResponseFactory
 78{
 079    public static QuiescenceStateDto MapState(QuiescenceState state) => new()
 080    {
 081        Reason = state.Reason.ToString(),
 082        IsAcceptingNewWork = state.IsAcceptingNewWork,
 083        PausedAt = state.PausedAt,
 084        DrainStartedAt = state.DrainStartedAt,
 085        PauseReasonText = state.PauseReasonText,
 086        PauseRequestedBy = state.PauseRequestedBy,
 087        GenerationId = state.GenerationId,
 088    };
 89
 090    public static IngressSourceStateDto MapSource(IngressSourceSnapshot s) => new()
 091    {
 092        Name = s.Name,
 093        State = s.State.ToString(),
 094        LastError = s.LastError?.Message,
 095        LastTransitionAt = s.LastTransitionAt,
 096    };
 97
 098    public static StatusResponse Build(RuntimeAdminStatus status) => new()
 099    {
 0100        State = MapState(status.State),
 0101        Sources = status.Sources.Select(MapSource).ToList(),
 0102        ActiveExecutionCycleCount = status.ActiveExecutionCycleCount,
 0103    };
 104}