Skip to main content

EndpointController

Struct EndpointController 

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

The per-endpoint adaptive controller.

This type contains no async machinery and can be driven by a deterministic simulator. reserve creates a virtual GCRA slot, while on_dispatched commits a slot only when the underlying service is genuinely ready.

Implementations§

Source§

impl EndpointController

Source

pub fn new(config: EndpointConfig, now: Instant) -> Self

Source

pub fn config(&self) -> &EndpointConfig

Source

pub fn pacer(&self) -> &Gcra

Source

pub fn gradient(&self) -> &Gradient2

Source

pub fn latency(&self) -> &LatencyEstimator

Source

pub fn probe(&self) -> &ProbeState

Source

pub fn queued(&self) -> usize

Source

pub fn inflight(&self) -> usize

Source

pub fn may_schedule(&self) -> bool

Source

pub fn reserve( &mut self, now: Instant, ) -> Result<DispatchReservation, ScheduleError>

Reserves one bounded scheduling slot and appends it to the virtual pacing queue.

Source

pub fn cancel(&mut self, reservation: DispatchReservation, now: Instant) -> bool

Drops an accepted but not-yet-dispatched request.

Cancellation is safe even when an earlier request remains queued: the virtual tail is rebuilt from the committed TAT, so a cancelled hole cannot permanently throttle the endpoint.

Source

pub fn dispatch_state( &mut self, reservation: DispatchReservation, now: Instant, ) -> DispatchState

Source

pub fn on_dispatched( &mut self, reservation: DispatchReservation, now: Instant, ) -> Option<InFlightRequest>

Commits the oldest reservation after the underlying service reports readiness. Dispatches are intentionally FIFO inside one endpoint.

Source

pub fn on_complete( &mut self, request: InFlightRequest, outcome: Outcome, latency: Duration, now: Instant, ) -> bool

Records a response and updates the endpoint’s operating point.

Source

pub fn on_admission_failure(&mut self, now: Instant)

Records an error obtained while the transport was being made ready. No request was dispatched, so this does not alter inflight accounting, but the endpoint is still penalized for future scheduling.

Source

pub fn start_positive_probe(&mut self, delta: f64, until: Instant, now: Instant)

Starts a temporary positive probe.

Source

pub fn start_negative_probe( &mut self, factor: f64, until: Instant, now: Instant, )

Starts a temporary negative probe.

Source

pub fn maybe_start_probe<R: Rng + ?Sized>( &mut self, schedule: &ProbeSchedule, rng: &mut R, now: Instant, ) -> Option<Probe>

Gives a seeded or production RNG a chance to start a temporary probe.

Source

pub fn refresh(&mut self, now: Instant)

Expires a probe, if necessary, and updates the pacer to the base rate.

Source

pub fn predicted_completion(&self, now: Instant) -> Instant

Predicts when one additional request would complete if current conditions remain stable.

Source

pub fn load(&self, now: Instant) -> f64

Returns a scalar suitable for comparing endpoints. Lower is better.

Source

pub fn snapshot(&mut self, now: Instant) -> ControllerSnapshot

Trait Implementations§

Source§

impl Debug for EndpointController

Source§

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

Formats the value using the given formatter. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.