Skip to main content

DnsIpPicker

Trait DnsIpPicker 

pub trait DnsIpPicker:
    Send
    + Sync
    + 'static {
    // Required method
    fn pick(
        &self,
        host: &Domain,
        resolution: &HostResolution,
    ) -> Result<Option<IpAddr>, Box<dyn Error + Send + Sync>>;
}
Available on crate feature dns only.
Expand description

Strategy that selects one IpAddr from a HostResolution.

Pickers should mostly be stateless themselves, any per-host state (e.g. a round-robin cursor) should live in the HostResolution::state extensions bag, which is scoped to the host and preserved across background DNS refreshes.

Required Methods§

fn pick( &self, host: &Domain, resolution: &HostResolution, ) -> Result<Option<IpAddr>, Box<dyn Error + Send + Sync>>

Pick one address from resolution.

Should return None if no IP has been picked. In that case the request will be forwarded to the inner service without any specific IP configured.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

§

impl DnsIpPicker for RandomPicker

§

impl DnsIpPicker for RoundRobinPicker

§

impl<T> DnsIpPicker for Arc<T>
where T: DnsIpPicker,

§

impl<T> DnsIpPicker for Box<T>
where T: DnsIpPicker,