pub trait LoadBalancingAlgorithm: Debug {
// Required method
fn next_available_backend(
&mut self,
key: Option<u64>,
candidates: Candidates<'_>,
) -> Option<Rc<RefCell<Backend>>>;
// Provided method
fn rebuild(&mut self, _backends: &[Rc<RefCell<Backend>>]) { ... }
}Required Methods§
Sourcefn next_available_backend(
&mut self,
key: Option<u64>,
candidates: Candidates<'_>,
) -> Option<Rc<RefCell<Backend>>>
fn next_available_backend( &mut self, key: Option<u64>, candidates: Candidates<'_>, ) -> Option<Rc<RefCell<Backend>>>
Select the next backend among candidates.
key carries an optional affinity hash: the UDP affinity key, or the
client key of an HTTP, HTTPS or TCP request (affinity_key_from_ip,
affinity_key_from_value). The
stateless/round-robin policies ignore it; the consistent-hashing
policies (Rendezvous, Maglev) use it to pin a key to a backend.
Passing None preserves the historical, key-agnostic behavior.
A policy reads the candidates through the borrowed Candidates view
and clones the Rc of the one backend it returns, nothing else, so a
selection allocates nothing.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".