1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Flagship coordination for multi-server fleet deployments
//!
//! When deploying multiple Motherships across different servers:
//! - **Uplinks** are verified on ALL instances (each checks its own connectivity)
//! - **Prelaunch/migrations** run on ONLY ONE instance (the Flagship)
//! - If the Flagship can't run migrations, the **entire deployment aborts**
//!
//! ## Election Backends
//!
//! - `static`: Explicit designation via env var or command output
//! - `postgres`: Automatic election via `pg_advisory_lock()` with LISTEN/NOTIFY signaling
//!
//! ## Example Configuration
//!
//! ```toml
//! [[mothership.uplinks]]
//! name = "primary-db"
//! url = "postgres://localhost:5432/myapp"
//!
//! [mothership.flagship]
//! enabled = true
//! election = "postgres"
//! election_uplink = "primary-db"
//! ```
//!
//! ## State Machine
//!
//! ```mermaid
//! stateDiagram-v2
//! [*] --> Starting
//! Starting --> VerifyUplinks
//! VerifyUplinks --> Electing
//! Electing --> RunningPrelaunch: Flagship
//! Electing --> WaitingForSignal: Escort
//! RunningPrelaunch --> SignalReady: Success
//! RunningPrelaunch --> SignalAbort: Failure
//! SignalReady --> LaunchFleet
//! WaitingForSignal --> LaunchFleet: Ready
//! WaitingForSignal --> Failed: Abort/Timeout
//! SignalAbort --> Failed
//! LaunchFleet --> Running
//! Running --> [*]
//! Failed --> [*]
//! ```
pub use ;
pub use ;
pub use PostgresElection;