using ZB.MOM.WW.Configuration; namespace ZB.MOM.WW.ScadaBridge.StoreAndForward; /// /// Validates at startup. The retry intervals /// feed the background sweep timer (a zero/negative period trips /// in the timer constructor) and the /// SQLite path is opened for the S&F buffer; an empty path yields an opaque /// connection failure at first enqueue. Registered with ValidateOnStart() /// so a bad ScadaBridge:StoreAndForward section fails fast at boot with a /// clear, key-naming message. /// public sealed class StoreAndForwardOptionsValidator : OptionsValidatorBase { /// protected override void Validate(ValidationBuilder builder, StoreAndForwardOptions options) { builder.RequireThat(!string.IsNullOrWhiteSpace(options.SqliteDbPath), "ScadaBridge:StoreAndForward:SqliteDbPath must be a non-empty path; " + "it is the SQLite file backing the store-and-forward buffer."); builder.RequireThat(options.DefaultRetryInterval > TimeSpan.Zero, $"ScadaBridge:StoreAndForward:DefaultRetryInterval must be a positive duration " + $"(was {options.DefaultRetryInterval}); it is the default per-message retry interval."); builder.RequireThat(options.RetryTimerInterval > TimeSpan.Zero, $"ScadaBridge:StoreAndForward:RetryTimerInterval must be a positive duration " + $"(was {options.RetryTimerInterval}); it is the background retry-sweep timer period."); builder.RequireThat(options.DefaultMaxRetries >= 0, $"ScadaBridge:StoreAndForward:DefaultMaxRetries must be >= 0 " + $"(was {options.DefaultMaxRetries})."); } }