| | | 1 | | using Elsa.Common; |
| | | 2 | | using JetBrains.Annotations; |
| | | 3 | | |
| | | 4 | | namespace 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] |
| | 79 | 21 | | public sealed class InitializePauseStateStartupTask(IQuiescenceSignal signal) : IStartupTask |
| | | 22 | | { |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public Task ExecuteAsync(CancellationToken cancellationToken) => |
| | 79 | 25 | | signal.InitializePersistedStateAsync(cancellationToken).AsTask(); |
| | | 26 | | } |