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

Method allow

crates/openshell-server/src/multiplex.rs:252–268  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

250 }
251
252 fn allow(&self) -> bool {
253 let now = Instant::now();
254 let mut state = self
255 .state
256 .lock()
257 .unwrap_or_else(std::sync::PoisonError::into_inner);
258 if now.duration_since(state.window_started) >= self.window {
259 state.window_started = now;
260 state.remaining = self.requests;
261 }
262 if state.remaining == 0 {
263 false
264 } else {
265 state.remaining -= 1;
266 true
267 }
268 }
269
270 /// Report whether the limiter currently has capacity without consuming a
271 /// token, rolling the window over first so an elapsed window reports

Callers 1

callMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected