36 lines
2.0 KiB
C#
36 lines
2.0 KiB
C#
using ZB.MOM.WW.Configuration;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.ManagementService;
|
|
|
|
/// <summary>
|
|
/// Validates <see cref="ManagementServiceOptions"/> at startup. Both
|
|
/// <see cref="ManagementServiceOptions.CommandTimeout"/> and
|
|
/// <see cref="ManagementServiceOptions.LongRunningCommandTimeout"/> are used as Ask timeouts against
|
|
/// the ManagementActor; a zero/negative value makes every management command fail immediately (or Ask
|
|
/// forever). Registered with <c>ValidateOnStart()</c> so a bad <c>ScadaBridge:ManagementService</c>
|
|
/// section fails fast at boot with a clear, key-naming message.
|
|
/// <para>
|
|
/// <see cref="ManagementServiceOptions.SecuredWritePendingTtl"/> is intentionally NOT required positive:
|
|
/// a non-positive value legitimately disables server-side secured-write expiry. The same holds for
|
|
/// <see cref="ManagementServiceOptions.SecuredWriteTerminalRetention"/> (non-positive disables the terminal-row purge).
|
|
/// </para>
|
|
/// </summary>
|
|
public sealed class ManagementServiceOptionsValidator : OptionsValidatorBase<ManagementServiceOptions>
|
|
{
|
|
/// <inheritdoc />
|
|
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.");
|
|
}
|
|
}
|