Skip to main content

Backends

Struct Backends 

Source
pub struct Backends { /* private fields */ }
Expand description

A discovered backend membership with view-local enablement and shared active health state.

Readiness is the conjunction of current view membership, view-local enablement, and the health state in the associated HealthRegistry.

Implementations§

Source§

impl Backends

Source

pub fn new(discovery: Box<dyn ServiceDiscovery + Send + Sync + 'static>) -> Self

Create a backend view with a private health registry.

Load balancers constructed from this view retain the existing behavior of scheduling their own health checks.

Source

pub fn new_with_health_registry( discovery: Box<dyn ServiceDiscovery + Send + Sync + 'static>, health_registry: Arc<HealthRegistry>, ) -> Self

Create a backend view that contributes targets to health_registry.

Health checks for shared views must be scheduled once through HealthCheckService instead of by every load balancer using the view. The registry must have a health check configured before that service is started.

Source

pub fn set_health_check( &mut self, hc: Box<dyn HealthCheck + Send + Sync + 'static>, )

Set the health check used by this view’s entire health registry.

Source

pub fn ready(&self, backend: &Backend) -> bool

Whether backend is enabled and healthy in this view’s current membership.

This is on the hot request path: it takes a single snapshot of the published view state and performs one map lookup to a BackendReadiness carrying both the view-local enablement flag and the shared Health handle, so no second registry snapshot is required.

Readiness is keyed by full backend identity. Only the current membership is reported: a removed backend is not ready here even while an older group selector can still return it through its own readiness snapshot.

Source

pub fn set_enable(&self, backend: &Backend, enabled: bool)

Manually enable or disable backend by full backend identity.

The current membership is updated in place. A removed backend is reached through the weak enablement-handle interner, so disabling or re-enabling a backend still held by an older group selector’s readiness snapshot takes effect for that selector too. Not on the request path, so it may take the interner lock. If the backend is unknown or no snapshot retains its enablement flag, this method does nothing.

Source

pub fn get_backend(&self) -> Arc<BTreeSet<Backend>>

Return this view’s current backend membership.

Source

pub async fn update<F>(&self, callback: F) -> Result<()>
where F: FnOnce(Arc<BTreeSet<Backend>>),

Run discovery and invoke callback when membership changes.

Calls on the same backend view must not overlap with another update.

Source

pub async fn run_health_check(&self, parallel: bool)

Run one health-check pass for this view’s entire registry.

Dropping the returned future cancels the pass, as described on HealthRegistry::run_health_check.

Trait Implementations§

Source§

impl Drop for Backends

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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