using ZB.MOM.WW.Configuration;
namespace ZB.MOM.WW.ScadaBridge.ManagementService;
///
/// Validates at startup. Both
/// and
/// are used as Ask timeouts against
/// the ManagementActor; a zero/negative value makes every management command fail immediately (or Ask
/// forever). Registered with ValidateOnStart() so a bad ScadaBridge:ManagementService
/// section fails fast at boot with a clear, key-naming message.
///
/// is intentionally NOT required positive:
/// a non-positive value legitimately disables server-side secured-write expiry. The same holds for
/// (non-positive disables the terminal-row purge).
///
///
public sealed class ManagementServiceOptionsValidator : OptionsValidatorBase
{
///
protected override void Validate(ValidationBuilder builder, ManagementServiceOptions options)
{
builder.RequireThat(options.CommandTimeout > TimeSpan.Zero,
$"ScadaBridge:ManagementService:CommandTimeout must be a positive duration " +
$"(was {options.CommandTimeout}); it is the Ask timeout for management commands.");
builder.RequireThat(options.LongRunningCommandTimeout > FlowDebug.FlowDebugRunner.ResponseGrace,
$"ScadaBridge:ManagementService:LongRunningCommandTimeout must exceed the 5-second response grace " +
$"(was {options.LongRunningCommandTimeout}); it is the Ask timeout for transport/deploy commands.");
builder.RequireThat(options.SecuredWriteTerminalPurgeInterval >= TimeSpan.Zero,
$"ScadaBridge:ManagementService:SecuredWriteTerminalPurgeInterval must not be negative " +
$"(was {options.SecuredWriteTerminalPurgeInterval}); zero purges on every Secured Writes list.");
}
}