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
impl Backends
Sourcepub fn new(discovery: Box<dyn ServiceDiscovery + Send + Sync + 'static>) -> Self
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.
Sourcepub fn new_with_health_registry(
discovery: Box<dyn ServiceDiscovery + Send + Sync + 'static>,
health_registry: Arc<HealthRegistry>,
) -> Self
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.
Sourcepub fn set_health_check(
&mut self,
hc: Box<dyn HealthCheck + Send + Sync + 'static>,
)
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.
Sourcepub fn ready(&self, backend: &Backend) -> bool
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.
Sourcepub fn set_enable(&self, backend: &Backend, enabled: bool)
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.
Sourcepub fn get_backend(&self) -> Arc<BTreeSet<Backend>> ⓘ
pub fn get_backend(&self) -> Arc<BTreeSet<Backend>> ⓘ
Return this view’s current backend membership.
Sourcepub async fn update<F>(&self, callback: F) -> Result<()>
pub async fn update<F>(&self, callback: F) -> Result<()>
Run discovery and invoke callback when membership changes.
Calls on the same backend view must not overlap with another update.
Sourcepub async fn run_health_check(&self, parallel: bool)
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.