| | | 1 | | using Elsa.Workflows.Management.Entities; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Workflows.Management.Models; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// The outcome of <see cref="IWorkflowDefinitionStore.TryUpdateLatestAsync"/>. |
| | | 7 | | /// </summary> |
| | | 8 | | public enum WorkflowDefinitionUpdateOutcome |
| | | 9 | | { |
| | | 10 | | /// <summary>The update ran and the definition was saved.</summary> |
| | | 11 | | Updated, |
| | | 12 | | |
| | | 13 | | /// <summary>No definition matched the filter.</summary> |
| | | 14 | | NotFound, |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// The loaded definition no longer matched what the caller expected — another writer saved first. |
| | | 18 | | /// </summary> |
| | | 19 | | Conflict |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// The result of a compare-and-swap update of the latest workflow definition. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <param name="Outcome">Whether the swap saved, found nothing, or lost the race.</param> |
| | | 26 | | /// <param name="Definition">The saved definition when <see cref="Outcome"/> is <see cref="WorkflowDefinitionUpdateOutco |
| | 18 | 27 | | public sealed record WorkflowDefinitionUpdateResult(WorkflowDefinitionUpdateOutcome Outcome, WorkflowDefinition? Definit |
| | | 28 | | { |
| | | 29 | | /// <summary>The update ran and <paramref name="definition"/> is what was saved.</summary> |
| | | 30 | | public static WorkflowDefinitionUpdateResult Updated(WorkflowDefinition definition) => |
| | 3 | 31 | | new(WorkflowDefinitionUpdateOutcome.Updated, definition); |
| | | 32 | | |
| | | 33 | | /// <summary>No definition matched the filter.</summary> |
| | 1 | 34 | | public static WorkflowDefinitionUpdateResult NotFound() => new(WorkflowDefinitionUpdateOutcome.NotFound); |
| | | 35 | | |
| | | 36 | | /// <summary>Another writer saved first; the caller's expected snapshot is no longer current.</summary> |
| | 3 | 37 | | public static WorkflowDefinitionUpdateResult Conflict() => new(WorkflowDefinitionUpdateOutcome.Conflict); |
| | | 38 | | } |