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
impl EndpointController
pub fn new(config: EndpointConfig, now: Instant) -> Self
pub fn config(&self) -> &EndpointConfig
pub fn pacer(&self) -> &Gcra
pub fn gradient(&self) -> &Gradient2
pub fn latency(&self) -> &LatencyEstimator
pub fn probe(&self) -> &ProbeState
pub fn queued(&self) -> usize
pub fn inflight(&self) -> usize
pub fn may_schedule(&self) -> bool
Sourcepub fn reserve(
&mut self,
now: Instant,
) -> Result<DispatchReservation, ScheduleError>
pub fn reserve( &mut self, now: Instant, ) -> Result<DispatchReservation, ScheduleError>
Reserves one bounded scheduling slot and appends it to the virtual pacing queue.
Sourcepub fn cancel(&mut self, reservation: DispatchReservation, now: Instant) -> bool
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.
pub fn dispatch_state( &mut self, reservation: DispatchReservation, now: Instant, ) -> DispatchState
Sourcepub fn on_dispatched(
&mut self,
reservation: DispatchReservation,
now: Instant,
) -> Option<InFlightRequest>
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.
Sourcepub fn on_complete(
&mut self,
request: InFlightRequest,
outcome: Outcome,
latency: Duration,
now: Instant,
) -> bool
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.
Sourcepub fn on_admission_failure(&mut self, now: Instant)
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.
Sourcepub fn start_positive_probe(&mut self, delta: f64, until: Instant, now: Instant)
pub fn start_positive_probe(&mut self, delta: f64, until: Instant, now: Instant)
Starts a temporary positive probe.
Sourcepub fn start_negative_probe(
&mut self,
factor: f64,
until: Instant,
now: Instant,
)
pub fn start_negative_probe( &mut self, factor: f64, until: Instant, now: Instant, )
Starts a temporary negative probe.
Sourcepub fn maybe_start_probe<R: Rng + ?Sized>(
&mut self,
schedule: &ProbeSchedule,
rng: &mut R,
now: Instant,
) -> Option<Probe>
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.
Sourcepub fn refresh(&mut self, now: Instant)
pub fn refresh(&mut self, now: Instant)
Expires a probe, if necessary, and updates the pacer to the base rate.
Sourcepub fn predicted_completion(&self, now: Instant) -> Instant
pub fn predicted_completion(&self, now: Instant) -> Instant
Predicts when one additional request would complete if current conditions remain stable.
Sourcepub fn load(&self, now: Instant) -> f64
pub fn load(&self, now: Instant) -> f64
Returns a scalar suitable for comparing endpoints. Lower is better.