pub struct BackendPool { /* private fields */ }Expand description
Thread-safe pool of backend addresses, optionally refreshed in the background.
Clone this type freely — all clones share the same underlying RwLock<Vec>.
Implementations§
Source§impl BackendPool
impl BackendPool
Sourcepub fn static(backends: Vec<String>) -> Self
pub fn static(backends: Vec<String>) -> Self
Create a pool from a fixed list of backends.
The list is available immediately; start() is a no-op.
Sourcepub fn env_prefix(prefix: impl Into<String>) -> Self
pub fn env_prefix(prefix: impl Into<String>) -> Self
Create a pool whose backends are read from environment variables
PREFIX_0, PREFIX_1, … at startup and every poll_interval_secs.
Sourcepub fn file(path: impl Into<String>) -> Self
pub fn file(path: impl Into<String>) -> Self
Create a pool whose backends are read from a file (one host:port per line).
Sourcepub fn dns(hostname: impl Into<String>, port: u16) -> Self
pub fn dns(hostname: impl Into<String>, port: u16) -> Self
Create a pool whose backends are discovered via DNS A-record lookup.
Sourcepub fn poll_interval_secs(self, secs: u64) -> Self
pub fn poll_interval_secs(self, secs: u64) -> Self
Override the background refresh interval (default: 30 seconds).
Only meaningful for File and Dns sources.
Sourcepub fn start(&self)
pub fn start(&self)
Start the background refresh thread.
For Static sources this is a no-op. For all others, an immediate
refresh() is performed before spawning the background thread so that
the first backends() call returns a populated list.
Trait Implementations§
Source§impl Clone for BackendPool
impl Clone for BackendPool
Source§fn clone(&self) -> BackendPool
fn clone(&self) -> BackendPool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more