dynomite/cluster/mod.rs
1//! Cluster layer: pools, peers, datacenters, racks, gossip,
2//! snitch, vnode dispatch, and the cluster-aware
3//! [`Dispatcher`](crate::net::Dispatcher) implementation.
4//!
5//! This module owns the cluster-wide data structures the C
6//! reference engine threaded through `struct server_pool` and the
7//! peer/dc/rack arrays. It is the seam between the per-connection
8//! state machines from [`crate::net`] (which only know about a
9//! single peer) and the routing logic that decides which peers
10//! receive a given request.
11//!
12//! Public surface:
13//!
14//! * [`peer::Peer`] / [`peer::PeerState`] - per-peer record.
15//! * [`datacenter::Datacenter`] / [`datacenter::Rack`] - topology.
16//! * [`vnode::dispatch`] - token ring lookup.
17//! * [`snitch`] - rack-distance helpers.
18//! * [`pool::ServerPool`] - cluster-wide owner.
19//! * [`gossip::GossipState`] / [`gossip::GossipConfig`] - gossip
20//! bookkeeping.
21//! * [`dispatch::ClusterDispatcher`] - the
22//! [`crate::net::Dispatcher`] implementation that replaces
23//! [`crate::net::NoopDispatcher`] for production wiring.
24//!
25//! # Examples
26//!
27//! ```
28//! use dynomite::cluster::peer::{Peer, PeerEndpoint};
29//! use dynomite::hashkit::DynToken;
30//! let p = Peer::new(
31//! 0,
32//! PeerEndpoint::tcp("127.0.0.1".into(), 8101),
33//! "rack1".into(),
34//! "dc1".into(),
35//! vec![DynToken::from_u32(1)],
36//! true,
37//! true,
38//! false,
39//! );
40//! assert_eq!(p.dc(), "dc1");
41//! ```
42
43pub mod admin_rpc;
44pub mod apl;
45pub mod capability;
46pub mod coverage;
47pub mod datacenter;
48pub mod dispatch;
49pub mod failure_detector;
50pub mod gossip;
51pub mod hints;
52pub mod peer;
53pub mod pool;
54pub mod snitch;
55pub mod vnode;
56
57pub use self::admin_rpc::{
58 ClusterAdmin, ClusterChange, ClusterChangeKind, ClusterError, JoinPlan, NoopClusterAdmin,
59 PeerSnapshot, PeerSpec, PoolClusterAdmin,
60};
61pub use self::apl::{get_apl_ann, AnnotatedPeer, NodeRole};
62
63pub use self::datacenter::{Continuum, Datacenter, Rack};
64pub use self::dispatch::{ClusterDispatcher, DispatchPlan, ReplicaTarget};
65pub use self::gossip::{
66 parse_seed_node, GossipConfig, GossipHandler, GossipNode, GossipState, GossipStep, SeedRecord,
67};
68pub use self::hints::{Hint, HintStore, HintStoreError, HintStoreStats};
69pub use self::peer::{Peer, PeerEndpoint, PeerState};
70pub use self::pool::{PoolConfig, ServerPool};
71pub use self::snitch::{rack_distance, RackDistance};
72pub use self::vnode::{dispatch as vnode_dispatch, rebuild_continuums, PeerTokens};