pub struct PowerOfTwoChoices;Expand description
Power of Two Choices: randomly pick two nodes, select the one with lower load.
Provides near-optimal load distribution with O(1) selection time,
a significant improvement over pure random while avoiding the overhead
of scanning all nodes like LeastLoad.
When fewer than two candidates are eligible, the sole eligible node is returned directly.
Implementations§
Trait Implementations§
Source§impl Debug for PowerOfTwoChoices
impl Debug for PowerOfTwoChoices
Source§impl Default for PowerOfTwoChoices
impl Default for PowerOfTwoChoices
Source§impl<N: LoadMetric> Strategy<N> for PowerOfTwoChoices
impl<N: LoadMetric> Strategy<N> for PowerOfTwoChoices
Source§fn select(&self, candidates: &[N], ctx: &SelectionContext) -> Option<usize>
fn select(&self, candidates: &[N], ctx: &SelectionContext) -> Option<usize>
Pick the next node. Returns
None when candidates is empty or all
candidates are excluded via SelectionContext::exclude.Auto Trait Implementations§
impl Freeze for PowerOfTwoChoices
impl RefUnwindSafe for PowerOfTwoChoices
impl Send for PowerOfTwoChoices
impl Sync for PowerOfTwoChoices
impl Unpin for PowerOfTwoChoices
impl UnsafeUnpin for PowerOfTwoChoices
impl UnwindSafe for PowerOfTwoChoices
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more