Skip to main content

LoadBalancer

Trait LoadBalancer 

Source
pub trait LoadBalancer<T>:
    Send
    + Sync
    + Clone
    + 'static {
    // Required methods
    fn alloc(&self) -> impl Future<Output = T> + Send;
    fn try_alloc(&self) -> Option<T>;
}
Expand description

A generic load balancer trait for allocating resources from a pool.

Implementors manage a collection of items and distribute them according to their specific strategy (round-robin, random, cooldown, etc.).

Required Methods§

Source

fn alloc(&self) -> impl Future<Output = T> + Send

Asynchronously allocate a resource from the pool.

Source

fn try_alloc(&self) -> Option<T>

Attempt to allocate a resource synchronously without awaiting.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl LoadBalancer<String> for ProxyPool

Source§

impl<T> LoadBalancer<T> for Cooldown<T>
where T: Send + Sync + Clone + 'static,

Source§

impl<T> LoadBalancer<T> for FaultTolerant<T>
where T: Clone + Send + Sync + 'static,

Source§

impl<T> LoadBalancer<T> for Random<T>
where T: Send + Sync + Clone + 'static,

Source§

impl<T> LoadBalancer<T> for RoundRobin<T>
where T: Send + Sync + Clone + 'static,

Source§

impl<T> LoadBalancer<T> for Window<T>
where T: Send + Sync + Clone + 'static,