| | | 1 | | namespace Elsa.Workflows.Runtime; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Domain service that backs the runtime's administrative pause / resume / force-drain / status surface. Endpoints |
| | | 5 | | /// (HTTP, MCP, CLI) compose this single service rather than re-implementing the orchestration + audit logic per |
| | | 6 | | /// transport. |
| | | 7 | | /// </summary> |
| | | 8 | | public interface IWorkflowRuntimeAdminService |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Places the runtime into <see cref="QuiescenceReason.AdministrativePause"/>. Idempotent — a second call with |
| | | 12 | | /// the runtime already paused returns the current state without publishing additional audit notifications |
| | | 13 | | /// (SC-007). |
| | | 14 | | /// </summary> |
| | | 15 | | ValueTask<QuiescenceState> PauseAsync(string? reason, string? requestedBy, CancellationToken cancellationToken); |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Clears <see cref="QuiescenceReason.AdministrativePause"/>. Returns the post-request state regardless of the |
| | | 19 | | /// outcome — callers detect "resume rejected because drain is active" by inspecting |
| | | 20 | | /// <see cref="QuiescenceState.Reason"/> against the original state. |
| | | 21 | | /// </summary> |
| | | 22 | | ValueTask<QuiescenceState> ResumeAsync(string? requestedBy, CancellationToken cancellationToken); |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Operator-escalation drain with zero deadline. Cancels every active execution cycle, persists their instances as |
| | | 26 | | /// <see cref="WorkflowSubStatus.Interrupted"/>, writes a <c>WorkflowInterrupted</c> log entry per affected |
| | | 27 | | /// instance, and returns the structured outcome. Throws <see cref="InvalidOperationException"/> when a |
| | | 28 | | /// non-force drain is already in progress in the same generation. |
| | | 29 | | /// </summary> |
| | | 30 | | ValueTask<DrainOutcome> ForceDrainAsync(string? reason, string? requestedBy, CancellationToken cancellationToken); |
| | | 31 | | |
| | | 32 | | /// <summary>Composite status for the admin status endpoint and any other diagnostic consumer.</summary> |
| | | 33 | | RuntimeAdminStatus GetStatus(); |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary>Snapshot returned by <see cref="IWorkflowRuntimeAdminService.GetStatus"/>.</summary> |
| | 0 | 37 | | public sealed record RuntimeAdminStatus( |
| | 0 | 38 | | QuiescenceState State, |
| | 0 | 39 | | IReadOnlyCollection<IngressSourceSnapshot> Sources, |
| | 0 | 40 | | int ActiveExecutionCycleCount); |