fix(r2-02): add ResiliencePolicyRanges single-source-of-truth to Core.Abstractions (01/S-6 task 1)

This commit is contained in:
Joseph Doherty
2026-07-13 09:51:05 -04:00
parent 1676c8f40f
commit 4be13429b6
2 changed files with 34 additions and 1 deletions
@@ -0,0 +1,33 @@
namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;
/// <summary>
/// Legal ranges for per-capability resilience policy values. Single source of truth shared by
/// <c>DriverResilienceOptionsParser</c> (clamp + diagnostic), <c>DriverResiliencePipelineBuilder</c>
/// (last-resort clamp so a pipeline build can never throw Polly's ValidationException), and the
/// AdminUI <c>ResilienceFormModel</c> (authoring-time validation messages). Derived from
/// Polly.Core 8.6.6's option validation: <c>TimeoutStrategyOptions.Timeout</c> ∈ [10 ms, 24 h];
/// <c>CircuitBreakerStrategyOptions.MinimumThroughput</c> ≥ 2.
/// </summary>
public static class ResiliencePolicyRanges
{
/// <summary>Minimum per-call timeout. Whole-second granularity puts the floor at 1 s (Polly's is 10 ms).</summary>
public const int MinTimeoutSeconds = 1;
/// <summary>Maximum per-call timeout — Polly's TimeoutStrategyOptions ceiling (24 h).</summary>
public const int MaxTimeoutSeconds = 86_400;
/// <summary>Retry floor; 0 = no retry strategy is added to the pipeline.</summary>
public const int MinRetryCount = 0;
/// <summary>Operational retry cap (Polly itself allows int.MaxValue; 100 exponential-backoff attempts ≈ minutes).</summary>
public const int MaxRetryCount = 100;
/// <summary>Breaker floor; 0 = no breaker strategy is added (the Tier C posture).</summary>
public const int MinBreakerFailureThreshold = 0;
/// <summary>Polly's MinimumThroughput floor — an enabled breaker needs a threshold of at least 2.</summary>
public const int MinEnabledBreakerFailureThreshold = 2;
/// <summary>Sanity cap on the breaker threshold (Polly has no ceiling; beyond this it can never trip in the 30 s window).</summary>
public const int MaxBreakerFailureThreshold = 10_000;
}