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

Function await_data_plane

nodedb/src/control/array_sync/raft_apply.rs:413–434  ·  view source on GitHub ↗

Await a Data Plane response, mapping timeout / channel-closed / error-status into `crate::Error::Internal` with a contextual `op_label`.

(
    rx: impl std::future::Future<Output = Result<Response, ()>>,
    op_label: &str,
)

Source from the content-addressed store, hash-verified

411/// Await a Data Plane response, mapping timeout / channel-closed / error-status
412/// into `crate::Error::Internal` with a contextual `op_label`.
413async fn await_data_plane(
414 rx: impl std::future::Future<Output = Result<Response, ()>>,
415 op_label: &str,
416) -> ProposeResult {
417 match tokio::time::timeout(Duration::from_secs(30), rx).await {
418 Ok(Ok(resp)) if resp.status == Status::Ok => Ok(resp.payload.to_vec()),
419 Ok(Ok(resp)) => {
420 let detail = resp
421 .error_code
422 .as_ref()
423 .map(|c| format!("{op_label} error: {c:?}"))
424 .unwrap_or_else(|| format!("{op_label} returned error status"));
425 Err(crate::Error::Internal { detail })
426 }
427 Ok(Err(_)) => Err(crate::Error::Internal {
428 detail: format!("{op_label}: response channel closed"),
429 }),
430 Err(_) => Err(crate::Error::Internal {
431 detail: format!("{op_label}: deadline exceeded"),
432 }),
433 }
434}

Callers 2

apply_array_opFunction · 0.85
ensure_array_openFunction · 0.85

Calls 2

to_vecMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected