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:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Transport;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DeploymentManager;
|
||||
@@ -27,8 +29,14 @@ public static class ServiceCollectionExtensions
|
||||
{
|
||||
// Ensure the options class is always resolvable.
|
||||
// The Host binds OptionsSection to appsettings.json; absent that binding
|
||||
// the declared option-class defaults apply.
|
||||
services.AddOptions<DeploymentManagerOptions>();
|
||||
// the declared option-class defaults apply. Eager startup validation
|
||||
// (arch-review 08 §1.5): ValidateOnStart makes a zero/negative timeout —
|
||||
// which would fire a linked-CTS deadline immediately (or throw in the
|
||||
// CancellationTokenSource ctor) — fail fast at boot with a clear,
|
||||
// key-naming message. Applies even though defaults are code-configured.
|
||||
services.AddOptions<DeploymentManagerOptions>().ValidateOnStart();
|
||||
services.TryAddEnumerable(
|
||||
ServiceDescriptor.Singleton<IValidateOptions<DeploymentManagerOptions>, DeploymentManagerOptionsValidator>());
|
||||
services.AddSingleton<OperationLockManager>();
|
||||
|
||||
// Push-based deployment-status notification. Registered
|
||||
|
||||
Reference in New Issue
Block a user