pub struct AdaptiveEndpoint<S> { /* private fields */ }Expand description
A Tower service with per-endpoint adaptive pacing and bounded admission.
poll_ready reports whether another request can enter the endpoint’s
bounded scheduling horizon. call reserves a virtual GCRA slot; the
returned future waits until that slot is due, waits for the inner service to
be ready, and only then records the actual dispatch. Queue delay therefore
never contaminates the RTT sample.
The endpoint is intentionally single-owner: Tower’s P2C balancer owns one service per discovered backend and does not require endpoint services to be cloneable. This lets readiness use the controller’s queue state directly, without a second shared allocation for coordinating cloned handles.
Implementations§
Source§impl<S> AdaptiveEndpoint<S>
impl<S> AdaptiveEndpoint<S>
Sourcepub fn new(inner: S, config: EndpointConfig) -> Self
pub fn new(inner: S, config: EndpointConfig) -> Self
Wraps a Tower endpoint using the current Tokio runtime time.
The returned service starts with an immediately available pacing slot.
§Panics
Panics when config contains invalid controller settings.
Sourcepub fn new_at(inner: S, config: EndpointConfig, now: Instant) -> Self
pub fn new_at(inner: S, config: EndpointConfig, now: Instant) -> Self
Sourcepub fn snapshot(&self) -> ControllerSnapshot
pub fn snapshot(&self) -> ControllerSnapshot
Returns a current snapshot of this endpoint’s controller.
Reading a snapshot refreshes time-driven probe state and may update the effective pacing rate.
Sourcepub fn load_metric(&self) -> LoadMetric
pub fn load_metric(&self) -> LoadMetric
Returns the endpoint’s predicted completion cost for load balancing.
Lower values are preferred. Reading the metric refreshes time-driven controller state, including probes.