//! SWIM-based cluster membership and failure detection.
//!
//! This module implements a SWIM-like protocol for managing cluster membership:
//!
//! - **Node Discovery**: New nodes discover existing members via seed nodes
//! - **Failure Detection**: Ping/indirect-probe mechanism with suspicion
//! - **Gossip Propagation**: Membership changes spread via piggybacked gossip
//!
//! # Protocol Overview
//!
//! The SWIM protocol operates in rounds:
//!
//! 1. **Ping Phase**: Each node pings a random peer every probe interval
//! 2. **Indirect Probe**: If ping fails, ask K random members to probe target
//! 3. **Suspicion**: Mark unresponsive nodes as suspect
//! 4. **Confirmation**: After timeout, mark suspect nodes as dead
//!
//! # Usage
//!
//! ```ignore
//! use stemedb_cluster::membership::{SwimMembership, SwimConfig};
//!
//! let config = SwimConfig::default();
//! let membership = SwimMembership::new(node_info, config).await?;
//!
//! // Join cluster via seed nodes
//! membership.join(seed_addrs).await?;
//!
//! // Subscribe to membership events
//! let mut events = membership.subscribe();
//! while let Ok(event) = events.recv().await {
//!     match event {
//!         MembershipEvent::NodeJoined(info) => println!("New node: {}", info.id),
//!         MembershipEvent::NodeFailed(id) => println!("Node failed: {}", id),
//!         _ => {}
//!     }
//! }
//!
//! // Graceful shutdown
//! membership.leave().await?;
//! ```

mod swim;
mod types;

pub use swim::SwimMembership;
pub use types::{MembershipEntry, MembershipEvent, NodeId, NodeInfo, NodeMetadata, NodeState};
