< Summary

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

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Lifecycle/InitializePauseStateShellInitializer.cs

#LineLine coverage
 1using CShells.Lifecycle;
 2using Elsa.Workflows.Runtime.Options;
 3using Elsa.Workflows.Runtime.Services;
 4
 5namespace Elsa.Workflows.Runtime.Lifecycle;
 6
 7/// <summary>
 8/// CShells <see cref="IShellInitializer"/> that re-applies any persisted administrative pause state when a shell
 9/// is activated. Without this hook, a shell configured for <see cref="PausePersistencePolicy.AcrossReactivations"/>
 10/// pause persistence would write the persisted key on pause but never read it on subsequent reactivations — meaning
 11/// the runtime would resume dispatching even though an operator had explicitly paused it before the previous
 12/// shell tear-down.
 13/// </summary>
 14/// <remarks>
 15/// <para>
 16/// This is the shell-aware counterpart of <c>InitializePauseStateStartupTask</c> (used by IModule consumers).
 17/// Both call <see cref="QuiescenceSignal.InitializePersistedStateAsync"/>, but they fire at different lifecycle
 18/// points:
 19/// </para>
 20/// <list type="bullet">
 21///   <item>
 22///     <description>
 23///     <c>IStartupTask</c> runs once when the IModule host starts up. Correct for non-shell deployments,
 24///     but in a shell-aware deployment a shell can be activated and reactivated independently of the host —
 25///     the startup task only fires for the FIRST activation.
 26///     </description>
 27///   </item>
 28///   <item>
 29///     <description>
 30///     <see cref="IShellInitializer"/> runs on EVERY shell activation, including reactivations after a reload.
 31///     This is what FR-028 requires: pause state survives every shell reactivation, not just the first.
 32///     </description>
 33///   </item>
 34/// </list>
 35/// </remarks>
 036public sealed class InitializePauseStateShellInitializer(IQuiescenceSignal signal) : IShellInitializer
 37{
 38    /// <inheritdoc />
 39    public Task InitializeAsync(CancellationToken cancellationToken = default) =>
 040        signal.InitializePersistedStateAsync(cancellationToken).AsTask();
 41}