Skip to main content

BackendMap

Struct BackendMap 

Source
pub struct BackendMap {
    pub backends: HashMap<ClusterId, BackendList>,
    pub max_failures: usize,
    pub health_check_configs: HashMap<ClusterId, HealthCheckConfig>,
    pub cluster_http2: HashMap<ClusterId, bool>,
}

Fields§

§backends: HashMap<ClusterId, BackendList>§max_failures: usize§health_check_configs: HashMap<ClusterId, HealthCheckConfig>§cluster_http2: HashMap<ClusterId, bool>

Whether the cluster’s backends speak HTTP/2 (cluster.http2 = true). Mirrors the same backend-capability hint the mux router reads at protocol/mux/router.rs::Router::connect. The health checker uses it to switch the probe wire format from HTTP/1.1 to h2c so an h2c-only backend is not probed with an HTTP/1.1 preface that would always fail.

Implementations§

Source§

impl BackendMap

Source

pub fn new() -> BackendMap

Source

pub fn set_cluster_http2(&mut self, cluster_id: &str, http2: bool)

Record (or clear) the cluster.http2 backend-capability hint for cluster_id. The health checker reads the resulting map at probe time so the wire format follows what the mux router will use to connect to the same backends.

Source

pub fn set_health_check_config( &mut self, cluster_id: &str, config: Option<HealthCheckConfig>, )

Source

pub fn import_configuration_state( &mut self, backends: &HashMap<ClusterId, Vec<Backend>>, )

Source

pub fn add_backend(&mut self, cluster_id: &str, backend: Backend)

Source

pub fn remove_backend( &mut self, cluster_id: &str, backend_address: &SocketAddr, ) -> Vec<String>

Remove every backend at backend_address from cluster_id and return the list of backend_ids that were dropped. Callers (e.g. Server::remove_backend) iterate over the returned ids to tear down per-backend metrics so the identity used by the runtime (address-keyed) matches the identity used by the metrics layer (id-keyed) — see PR #1252 follow-up review MEDIUM-3.

Source

pub fn close_backend_connection(&mut self, cluster_id: &str, addr: &SocketAddr)

Source

pub fn has_backend(&self, cluster_id: &str, backend: &Backend) -> bool

Source

pub fn backend_from_cluster_id( &mut self, cluster_id: &str, ) -> Result<(Rc<RefCell<Backend>>, TcpStream), BackendError>

Source

pub fn backend_from_cluster_id_with_key( &mut self, cluster_id: &str, key: Option<u64>, ) -> Result<(String, SocketAddr), BackendError>

Select a backend for cluster_id, optionally pinned by an affinity key, and return its (backend_id, address) without opening any connection.

This is the UDP datapath’s selection entry point. Unlike backend_from_cluster_id — which is TCP-specific because it calls Backend::try_connect and hands back a TcpStream — UDP owns its own per-flow connected UdpSocket (created in the shell via socket::udp_connect), so all the map needs to surface is the chosen endpoint identity. key is Some(flow_hash) so HRW/Maglev keep a client flow pinned to one backend; None behaves like the legacy round-robin selection. Fail-open (all-unhealthy ⇒ LB over the full set) is inherited from BackendList::next_available_backend_with_key.

Source

pub fn backend_from_sticky_session( &mut self, cluster_id: &str, sticky_session: &str, ) -> Result<(Rc<RefCell<Backend>>, TcpStream), BackendError>

Source

pub fn set_load_balancing_policy_for_cluster( &mut self, cluster_id: &str, lb_algo: LoadBalancingAlgorithms, metric: Option<LoadMetric>, )

Source

pub fn get_or_create_backend_list_for_cluster( &mut self, cluster_id: &str, ) -> &mut BackendList

Trait Implementations§

Source§

impl Debug for BackendMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BackendMap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more