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

Method has_capacity

crates/openshell-server/src/multiplex.rs:278–289  ·  view source on GitHub ↗

Report whether the limiter currently has capacity without consuming a token, rolling the window over first so an elapsed window reports capacity again. Used by `poll_ready` so an exhausted limiter reports readiness instead of blocking on inner-service backpressure: `call` can then return `RESOURCE_EXHAUSTED` immediately rather than waiting for the inner gRPC service to become ready.

(&self)

Source from the content-addressed store, hash-verified

276 /// `RESOURCE_EXHAUSTED` immediately rather than waiting for the inner gRPC
277 /// service to become ready.
278 fn has_capacity(&self) -> bool {
279 let now = Instant::now();
280 let mut state = self
281 .state
282 .lock()
283 .unwrap_or_else(std::sync::PoisonError::into_inner);
284 if now.duration_since(state.window_started) >= self.window {
285 state.window_started = now;
286 state.remaining = self.requests;
287 }
288 state.remaining > 0
289 }
290}
291
292#[derive(Clone)]

Callers 1

poll_readyMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected