/
ISaga.cs
94 lines (80 loc) · 3.49 KB
/
ISaga.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using Sagaway.Telemetry;
namespace Sagaway;
public interface ISaga<in TEOperations> where TEOperations : Enum
{
/// <summary>
/// Execute the saga
/// </summary>
/// <returns>Async method</returns>
Task RunAsync();
/// <summary>
/// Call when all saga operations are completed
/// </summary>
event EventHandler<SagaCompletionEventArgs> OnSagaCompleted;
/// <summary>
/// The saga is in progress
/// </summary>
bool InProgress { get; }
/// <summary>
/// All operations have been executed successfully and the saga is completed
/// </summary>
// ReSharper disable once UnusedMemberInSuper.Global
bool Succeeded { get; }
/// <summary>
/// The saga has failed and is in the process of reverting
/// </summary>
// ReSharper disable once UnusedMemberInSuper.Global
bool Failed { get; }
/// <summary>
/// The saga has failed and has reverted all operations
/// </summary>
// ReSharper disable once UnusedMemberInSuper.Global
bool Reverted { get; }
/// <summary>
/// The saga has failed and has failed to revert all operations. It is considered done.
/// </summary>
// ReSharper disable once UnusedMemberInSuper.Global
bool RevertFailed { get; }
/// <summary>
/// Implementer should call this method to inform an activated event
/// </summary>
/// <returns>Async operation</returns>
Task InformActivatedAsync();
/// <summary>
/// Implementer should call this method to inform a deactivated event
/// </summary>
/// <returns>Async operation</returns>
Task InformDeactivatedAsync();
/// <summary>
/// Implementer should call this method to inform the outcome of an operation
/// </summary>
/// <param name="operation">The operation</param>
/// <param name="success">Success or failure</param>
/// <param name="failFast">If true, fail the Saga, stop retries and start revert</param>
/// <returns>Async operation</returns>
[Obsolete("Use ReportOperationOutcomeAsync with the FastOutcome enum instead")]
Task ReportOperationOutcomeAsync(TEOperations operation, bool success, bool failFast);
/// <summary>
/// Implementer should call this method to inform the outcome of an operation
/// </summary>
/// <param name="operation">The operation</param>
/// <param name="success">Success or failure</param>
/// <param name="sagaFastOutcome">Inform a fast outcome for the Saga from a single operation, either fast fail or success
/// <remarks><see cref="SagaFastOutcome.Failure"/> fails the saga and start the compensation process</remarks>
/// <remarks><see cref="SagaFastOutcome.Success"/> Finish the saga successfully, marked all non-started operations as succeeded</remarks></param>
/// <returns>Async operation</returns>
Task ReportOperationOutcomeAsync(TEOperations operation, bool success, SagaFastOutcome sagaFastOutcome = SagaFastOutcome.None);
/// <summary>
/// Implementer should call this method to inform the outcome of an undo operation
/// </summary>
/// <param name="operation">The operation</param>
/// <param name="success">Success or failure</param>
/// <returns>Async operation</returns>
Task ReportUndoOperationOutcomeAsync(TEOperations operation, bool success);
/// <summary>
/// Call the saga to handle reminder operations
/// </summary>
/// <param name="reminder"></param>
/// <returns>Async operation</returns>
Task ReportReminderAsync(string reminder);
}