MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / poll_ready

Method poll_ready

crates/openshell-server/src/multiplex.rs:325–346  ·  view source on GitHub ↗
(&mut self, cx: &mut Context<'_>)

Source from the content-addressed store, hash-verified

323 type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
324
325 fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
326 // When the limiter is exhausted, report ready so `call` can return
327 // RESOURCE_EXHAUSTED immediately. Delegating to the inner service here
328 // would make rate-limited requests wait on inner backpressure (a
329 // pending inner `poll_ready`) before they are rejected. The check is
330 // non-consuming: the token is only consumed in `call` via `allow`.
331 //
332 // Crucially, this path does NOT poll the inner service, so the inner
333 // service has not reported readiness. Record that decision so the
334 // paired `call` rejects rather than forwarding to a service that never
335 // became ready — even if the rate-limit window rolls over in between.
336 if self
337 .limiter
338 .as_ref()
339 .is_some_and(|limiter| !limiter.has_capacity())
340 {
341 self.rate_limited = true;
342 return Poll::Ready(Ok(()));
343 }
344 self.rate_limited = false;
345 self.inner.poll_ready(cx)
346 }
347
348 fn call(&mut self, req: Request<B>) -> Self::Future {
349 // If `poll_ready` short-circuited an exhausted limiter, it never polled

Callers

nothing calls this directly

Calls 1

has_capacityMethod · 0.80

Tested by

no test coverage detected