fix: wire ValidateOnStart for ScadaBridge HealthMonitoring + Cluster options (fail-fast at startup)
This commit is contained in:
@@ -105,10 +105,16 @@ public static class SiteServiceRegistration
|
|||||||
public static void BindSharedOptions(IServiceCollection services, IConfiguration config)
|
public static void BindSharedOptions(IServiceCollection services, IConfiguration config)
|
||||||
{
|
{
|
||||||
services.Configure<NodeOptions>(config.GetSection("ScadaBridge:Node"));
|
services.Configure<NodeOptions>(config.GetSection("ScadaBridge:Node"));
|
||||||
services.Configure<ClusterOptions>(config.GetSection("ScadaBridge:Cluster"));
|
// Bind + eagerly validate: ClusterOptionsValidator is registered (TryAddEnumerable)
|
||||||
|
// by the ClusterInfrastructure module, so chaining ValidateOnStart() here makes a bad
|
||||||
|
// ScadaBridge:Cluster section fail fast at host build instead of lazily on first resolve.
|
||||||
|
services.AddOptions<ClusterOptions>().Bind(config.GetSection("ScadaBridge:Cluster")).ValidateOnStart();
|
||||||
services.Configure<DatabaseOptions>(config.GetSection("ScadaBridge:Database"));
|
services.Configure<DatabaseOptions>(config.GetSection("ScadaBridge:Database"));
|
||||||
services.Configure<CommunicationOptions>(config.GetSection("ScadaBridge:Communication"));
|
services.Configure<CommunicationOptions>(config.GetSection("ScadaBridge:Communication"));
|
||||||
services.Configure<HealthMonitoringOptions>(config.GetSection("ScadaBridge:HealthMonitoring"));
|
// Bind + eagerly validate: HealthMonitoringOptionsValidator is registered (TryAddEnumerable)
|
||||||
|
// by the HealthMonitoring module, so chaining ValidateOnStart() here makes a bad
|
||||||
|
// ScadaBridge:HealthMonitoring section fail fast at host build instead of lazily on first resolve.
|
||||||
|
services.AddOptions<HealthMonitoringOptions>().Bind(config.GetSection("ScadaBridge:HealthMonitoring")).ValidateOnStart();
|
||||||
services.Configure<NotificationOptions>(config.GetSection("ScadaBridge:Notification"));
|
services.Configure<NotificationOptions>(config.GetSection("ScadaBridge:Notification"));
|
||||||
services.Configure<LoggingOptions>(config.GetSection("ScadaBridge:Logging"));
|
services.Configure<LoggingOptions>(config.GetSection("ScadaBridge:Logging"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user