Expand description
Cluster-aware Dispatcher.
Routes parsed Msgs based on the configured consistency level
and the crate::cluster::pool::ServerPool topology:
DC_ONEreads pick the rack-local replica via the snitch.DC_ONEwrites fan out to every replica in the local DC.DC_QUORUM/DC_SAFE_QUORUMreads fan out to every replica in the local DC.DC_EACH_SAFE_QUORUMwrites fan out per-DC, walking the per-DC racks via the preselected rack fromcrate::cluster::pool::ServerPool::preselect_remote_racks.
The actual outbound delivery happens through the per-peer
crate::net::ConnPools; this module produces a
DispatchPlan (the list of replica peers a request must be
routed to) and exposes the planning logic so it can be tested
independently of the runtime fan-out.
§Examples
use dynomite::cluster::dispatch::{ClusterDispatcher, DispatchPlan};
use dynomite::cluster::pool::{PoolConfig, ServerPool};
use dynomite::cluster::peer::{Peer, PeerEndpoint};
use dynomite::hashkit::DynToken;
use dynomite::msg::{Msg, MsgType};
use std::sync::Arc;
let cfg = PoolConfig {
dc: "d".into(), rack: "r".into(),
..PoolConfig::default()
};
let local = Peer::new(
0, PeerEndpoint::tcp("h".into(), 1), "r".into(), "d".into(),
vec![DynToken::from_u32(0)], true, true, false,
);
let pool = Arc::new(ServerPool::new(cfg, vec![local]));
let disp = ClusterDispatcher::new(pool);
let req = Msg::new(1, MsgType::ReqRedisGet, true);
let plan = disp.plan(&req, b"foo");
assert!(matches!(plan, DispatchPlan::LocalDatastore));Structs§
- Cluster
Dispatcher - Cluster-aware dispatcher.
- Replica
Target - One replica target produced by
ClusterDispatcher::plan.
Enums§
- Dispatch
Plan - Dispatch plan produced by the cluster dispatcher.
Functions§
- distribution_
shadow_ disagreement_ total - Process-global Prometheus-friendly counter of
shadow-distribution disagreements. The dispatcher bumps this
counter every time the configured
distributionand the configureddistribution_shadowchoose different peers for the same key. Exposed for both the stats endpoint and the integration test that exercises shadow mode. - reset_
distribution_ shadow_ disagreement_ total - Reset the shadow-disagreement counter. Used by integration tests that need a clean baseline; never called from production code.