< Summary

Information
Class: Elsa.Workflows.Runtime.StartupTasks.InitializePauseStateStartupTask
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/StartupTasks/InitializePauseStateStartupTask.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 26
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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
ExecuteAsync(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/StartupTasks/InitializePauseStateStartupTask.cs

#LineLine coverage
 1using Elsa.Common;
 2using JetBrains.Annotations;
 3
 4namespace Elsa.Workflows.Runtime.StartupTasks;
 5
 6/// <summary>
 7/// Startup task that re-applies any persisted administrative pause via <see cref="IQuiescenceSignal.InitializePersisted
 8/// Without it, a host configured for across-reactivations pause persistence would write the persisted key on
 9/// pause but never read it on subsequent startups, leaving the runtime dispatching despite an operator having
 10/// explicitly paused it before the previous shutdown. See FR-028 / research R8.
 11/// </summary>
 12/// <remarks>
 13/// This task MUST run on every node — it deliberately does NOT carry <c>[SingleNodeTask]</c>.
 14/// <see cref="IQuiescenceSignal"/> is registered as a singleton in each node's DI container, so each node holds
 15/// its own in-memory <see cref="QuiescenceState"/>. Gating the task to a single cluster winner would leave every
 16/// other node starting with <see cref="QuiescenceReason.None"/> and dispatching new work, silently defeating the
 17/// persisted pause. The per-shell counterpart for shell-aware deployments is
 18/// <c>InitializePauseStateShellInitializer</c>, which fires per-shell (and therefore per-node) for the same reason.
 19/// </remarks>
 20[UsedImplicitly]
 7921public sealed class InitializePauseStateStartupTask(IQuiescenceSignal signal) : IStartupTask
 22{
 23    /// <inheritdoc />
 24    public Task ExecuteAsync(CancellationToken cancellationToken) =>
 7925        signal.InitializePersistedStateAsync(cancellationToken).AsTask();
 26}