namespace ScadaLink.ClusterInfrastructure; /// /// Cluster configuration model, bound from the ScadaLink:Cluster section /// of appsettings.json via the Options pattern. /// /// This project owns the cluster configuration contract. The actual /// Akka.NET bootstrap — building the HOCON from these values, starting the /// ActorSystem, configuring the split-brain resolver and wiring /// CoordinatedShutdown — lives in ScadaLink.Host /// (see Component-ClusterInfrastructure.md → "Implementation Note — Code Placement"). /// /// /// Node-identity settings (remoting hostname/port, cluster role, site identifier, /// gRPC port) are deliberately not here — they are owned by /// ScadaLink.Host.NodeOptions (ScadaLink:Node section). Local SQLite /// storage paths are owned by the database / store-and-forward options. This class /// holds only the cluster-formation and failure-detection settings shared by every node. /// /// public class ClusterOptions { /// /// The appsettings.json section name this options class binds from. /// Single source of truth so binding sites do not hard-code the magic string. /// public const string SectionName = "ScadaLink:Cluster"; /// /// Akka.NET cluster seed nodes. Both nodes are seed nodes — each node lists /// itself and its partner — so either can start first and form the cluster. /// Must contain at least one entry. /// public List SeedNodes { get; set; } = new(); /// /// Split-brain resolver strategy. Must be keep-oldest for the two-node /// clusters ScadaLink uses: quorum strategies (keep-majority, /// static-quorum) cannot distinguish a crash from a partition with only /// two nodes and would shut down the whole cluster. /// public string SplitBrainResolverStrategy { get; set; } = "keep-oldest"; /// /// Time the cluster membership must remain stable before the split-brain /// resolver acts to down unreachable nodes. Must be positive. Default 15s. /// public TimeSpan StableAfter { get; set; } = TimeSpan.FromSeconds(15); /// /// Frequency of cluster failure-detector heartbeat messages between nodes. /// Must be well below . Default 2s. /// public TimeSpan HeartbeatInterval { get; set; } = TimeSpan.FromSeconds(2); /// /// Time without a heartbeat before a node is considered unreachable /// (Akka's acceptable-heartbeat-pause). Default 10s. /// public TimeSpan FailureDetectionThreshold { get; set; } = TimeSpan.FromSeconds(10); /// /// Akka's min-nr-of-members. Must be 1: after failover only one /// node runs, and a value of 2 blocks the cluster singleton (Site Runtime /// Deployment Manager) — and therefore all data collection — indefinitely. /// public int MinNrOfMembers { get; set; } = 1; /// /// The keep-oldest resolver's down-if-alone flag. When true (the /// design-doc requirement), the oldest node downs itself if it finds it has no /// other reachable members, rather than running as an isolated single-node cluster. /// public bool DownIfAlone { get; set; } = true; }