MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / drain_and_reject

Function drain_and_reject

nodedb/src/data/runtime.rs:384–405  ·  view source on GitHub ↗

Drain all pending requests from a core's SPSC queue and send back `CoreDegraded` error responses. Used when the watchdog has flagged the core as unhealthy.

(core: &mut CoreLoop, core_id: usize)

Source from the content-addressed store, hash-verified

382/// `CoreDegraded` error responses. Used when the watchdog has flagged
383/// the core as unhealthy.
384fn drain_and_reject(core: &mut CoreLoop, core_id: usize) {
385 core.drain_requests();
386 while let Some(task) = core.task_queue.pop_front() {
387 let response = Response {
388 request_id: task.request_id(),
389 status: Status::Error,
390 attempt: 1,
391 partial: false,
392 payload: Payload::empty(),
393 watermark_lsn: core.watermark,
394 error_code: Some(ErrorCode::Internal {
395 detail: format!("core-{core_id} is degraded after repeated panics"),
396 }),
397 };
398 if let Err(e) = core
399 .response_tx
400 .try_push(BridgeResponse { inner: response })
401 {
402 warn!(core_id, error = %e, "failed to send degraded-rejection response");
403 }
404 }
405}
406
407/// Compute heartbeat interval with ±100ms jitter.
408///

Callers 1

spawn_coreFunction · 0.85

Calls 5

pop_frontMethod · 0.80
request_idMethod · 0.80
try_pushMethod · 0.80
emptyFunction · 0.50
drain_requestsMethod · 0.45

Tested by

no test coverage detected