Skip to main content

round_robin_assignment

Function round_robin_assignment 

Source
pub fn round_robin_assignment(
    vnode_count: u32,
    peers: &[NodeId],
) -> Arc<[NodeId]>
Expand description

Build a vnode-to-owner assignment by round-robin across sorted peers.

Deterministic for a given (vnode_count, peers) input โ€” every node computing this independently agrees, given the same peer list. Uses sort-by-id + modulo: vnode v โ†’ peers[v % peers.len()] after sorting. Simple and fine for uniform key distributions.

Not consistent hashing โ€” a peer join/leave reshuffles every vnode. Acceptable for the current phase since reassignment happens only at cluster start; dynamic rebalance is deferred work.

ยงPanics

Panics if peers is empty.