Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

Cluster-aware Dispatcher.

Routes parsed Msgs based on the configured consistency level and the crate::cluster::pool::ServerPool topology:

  • DC_ONE reads pick the rack-local replica via the snitch.
  • DC_ONE writes fan out to every replica in the local DC.
  • DC_QUORUM / DC_SAFE_QUORUM reads fan out to every replica in the local DC.
  • DC_EACH_SAFE_QUORUM writes fan out per-DC, walking the per-DC racks via the preselected rack from crate::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§

ClusterDispatcher
Cluster-aware dispatcher.
ReplicaTarget
One replica target produced by ClusterDispatcher::plan.

Enums§

DispatchPlan
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 distribution and the configured distribution_shadow choose 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.