| | | 1 | | namespace AsyncResponse; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Options for the process-local response channel registered by |
| | | 5 | | /// <c>AddAsyncResponse().WithInMemoryChannel()</c>. Waiters, subscriptions, and recovery state |
| | | 6 | | /// all live in memory and disappear when the process exits. |
| | | 7 | | /// </summary> |
| | | 8 | | // Derives from the DURABLE options despite holding nothing durable: the wire channels serialize |
| | | 9 | | // failures (message + capped stack trace, type erased), and the in-memory channel reproduces that |
| | | 10 | | // so tests exercise the same failure shape production sees — including these two policy knobs. |
| | | 11 | | public sealed class InMemoryAsyncResponseOptions : DurableAsyncResponseChannelOptions |
| | | 12 | | { |
| | | 13 | | /// <summary>Runs the InMemoryAsyncResponseOptions operation.</summary> |
| | 1310 | 14 | | public InMemoryAsyncResponseOptions() |
| | | 15 | | { |
| | | 16 | | // Process-local recovery state is not durable (entries are lost on exit), so a short default |
| | | 17 | | // keeps stale state from lingering — unlike the durable channels' 7-day default. |
| | 1310 | 18 | | RecoveryStateExpiry = TimeSpan.FromMinutes(30); |
| | 1310 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Validates the options, throwing an actionable <see cref="InvalidOperationException"/> on |
| | | 23 | | /// misconfiguration — the same guard set every durable channel applies, so a configuration |
| | | 24 | | /// that passes the in-memory harness cannot fail host startup on a real channel. |
| | | 25 | | /// </summary> |
| | | 26 | | internal void Validate() |
| | | 27 | | { |
| | 1274 | 28 | | ValidateShared(nameof(InMemoryAsyncResponseOptions)); |
| | | 29 | | // RemoteStackTrace.Cap treats a non-positive cap as "no cap", so without this the bound |
| | | 30 | | // on remote traces was silently disabled here while all five wire channels reject it. |
| | 1270 | 31 | | if (MaxRemoteStackTraceLength < 0) |
| | 2 | 32 | | throw new InvalidOperationException($"{nameof(InMemoryAsyncResponseOptions)}.{nameof(MaxRemoteStackTraceLeng |
| | 1268 | 33 | | } |
| | | 34 | | } |