| | | 1 | | namespace AsyncResponse; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Marker for payload models awaited through <see cref="IAsyncResponseBuilder.For{T}(string)"/> and |
| | | 5 | | /// <see cref="IAsyncResponseBuilder.For{T}()"/>. Implement this on your DTO/class/record to opt in. |
| | | 6 | | /// Using an interface intentionally excludes primitive and scalar BCL types such as |
| | | 7 | | /// <see cref="string"/>, <see cref="int"/>, <see cref="bool"/>, <see cref="Guid"/>, and |
| | | 8 | | /// <see cref="DateTime"/>. |
| | | 9 | | /// </summary> |
| | | 10 | | public interface IAsyncResponsePayload |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Decides — for the <em>lost-subscriber</em> recovery path only — whether a late response of |
| | | 14 | | /// this type should <em>resume</em> the flow or <em>fail</em> it. |
| | | 15 | | /// <para> |
| | | 16 | | /// This is consulted exclusively when a response arrives with no live waiter (typically after a |
| | | 17 | | /// redeploy): the recovering process has the persisted recovery state and the payload, but not |
| | | 18 | | /// the original waiter — so the resume-vs-fail decision must be reconstructible from the payload |
| | | 19 | | /// type itself. <c>true</c> routes the payload to the resume callback |
| | | 20 | | /// (<c>OnLostSubscriberResume</c>); <c>false</c> routes it to the failure callback |
| | | 21 | | /// (<c>OnLostSubscriberFailure</c>), wrapped in an |
| | | 22 | | /// <see cref="AsyncResponseDomainFailureException"/>. |
| | | 23 | | /// </para> |
| | | 24 | | /// <para> |
| | | 25 | | /// It has <strong>nothing to do with live completion</strong>: an active waiter decides when to |
| | | 26 | | /// stop with its <c>Until(...)</c> predicate and this method is never called on that path. The |
| | | 27 | | /// two answer different questions — <c>Until</c> asks "is the operation done?", this asks "is |
| | | 28 | | /// this result a failure?". |
| | | 29 | | /// </para> |
| | | 30 | | /// <para> |
| | | 31 | | /// The default returns <c>false</c> (do not resume) so that a payload never resumes a flow by |
| | | 32 | | /// omission — a failed response can never accidentally take the happy path. Override it only for |
| | | 33 | | /// payloads used with <see cref="IRecoverableAsyncResponseBuilder"/> that can carry a domain |
| | | 34 | | /// failure, returning <c>true</c> for the states the flow should resume on. Durable channels |
| | | 35 | | /// (e.g. Redis) require this override when recovery callbacks are registered, and fail fast at |
| | | 36 | | /// waiter creation if it is missing. |
| | | 37 | | /// </para> |
| | | 38 | | /// </summary> |
| | 3 | 39 | | bool ShouldResumeOnRecovery() => false; |
| | | 40 | | } |