feat(options): eager startup validation for central-component options (Transport, SiteCallAudit, DeploymentManager) (arch-review 08 §1.5)
Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using ZB.MOM.WW.Configuration;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DeploymentManager;
|
||||
|
||||
/// <summary>
|
||||
/// Validates <see cref="DeploymentManagerOptions"/> at startup. Each timeout is
|
||||
/// applied as a linked-CTS deadline around a lifecycle command, per-site artifact
|
||||
/// deployment, or operation-lock acquisition; a zero/negative value makes the
|
||||
/// deadline fire immediately (or the <see cref="System.Threading.CancellationTokenSource"/>
|
||||
/// constructor throw), breaking deployments with an opaque failure. Registered
|
||||
/// with <c>ValidateOnStart()</c> so a bad <c>ScadaBridge:DeploymentManager</c>
|
||||
/// section fails fast at boot with a clear, key-naming message.
|
||||
/// </summary>
|
||||
public sealed class DeploymentManagerOptionsValidator : OptionsValidatorBase<DeploymentManagerOptions>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Validate(ValidationBuilder builder, DeploymentManagerOptions options)
|
||||
{
|
||||
builder.RequireThat(options.LifecycleCommandTimeout > TimeSpan.Zero,
|
||||
$"ScadaBridge:DeploymentManager:LifecycleCommandTimeout must be a positive duration " +
|
||||
$"(was {options.LifecycleCommandTimeout}); it bounds a lifecycle command round-trip.");
|
||||
|
||||
builder.RequireThat(options.ArtifactDeploymentTimeoutPerSite > TimeSpan.Zero,
|
||||
$"ScadaBridge:DeploymentManager:ArtifactDeploymentTimeoutPerSite must be a positive duration " +
|
||||
$"(was {options.ArtifactDeploymentTimeoutPerSite}); it bounds per-site artifact deployment.");
|
||||
|
||||
builder.RequireThat(options.OperationLockTimeout > TimeSpan.Zero,
|
||||
$"ScadaBridge:DeploymentManager:OperationLockTimeout must be a positive duration " +
|
||||
$"(was {options.OperationLockTimeout}); it bounds acquiring an instance operation lock.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user