using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace ScadaLink.ClusterInfrastructure; /// /// DI registration for the Cluster Infrastructure component. /// public static class ServiceCollectionExtensions { /// /// Registers the Cluster Infrastructure services. This component owns the /// cluster configuration contract (); the /// Akka.NET bootstrap itself lives in ScadaLink.Host /// (see Component-ClusterInfrastructure.md). /// /// Registering the means a misconfigured /// ScadaLink:Cluster section (e.g. MinNrOfMembers: 2 or a quorum /// split-brain strategy) throws an the /// first time is resolved, rather than booting /// into a broken cluster. /// /// public static IServiceCollection AddClusterInfrastructure(this IServiceCollection services) { services.TryAddEnumerable( ServiceDescriptor.Singleton, ClusterOptionsValidator>()); return services; } /// /// Reserved for cluster-infrastructure actor registration. This component does /// not register any actors — the Akka.NET bootstrap and actor wiring live in /// ScadaLink.Host. The method throws rather than silently returning /// success so that any caller assuming this component registers actors fails /// fast with a clear cause instead of failing later, far from here. /// /// Always thrown. public static IServiceCollection AddClusterInfrastructureActors(this IServiceCollection services) { throw new NotImplementedException( "ScadaLink.ClusterInfrastructure registers no actors. The Akka.NET actor system " + "bootstrap and all cluster actor registration live in ScadaLink.Host " + "(AkkaHostedService). Do not call AddClusterInfrastructureActors()."); } }