MCPcopy Create free account
hub / github.com/deventlab/d-engine / scan_prefix

Method scan_prefix

d-engine-server/src/api/embedded_client.rs:633–653  ·  view source on GitHub ↗

Scan all keys under `prefix` with linearizable consistency. Returns a `ScanResult` containing all matching `(key, value)` pairs and the `revision` (applied index) at scan time. Use `revision` to filter watch events during reconnection: skip events where `event.revision <= revision`.

(
        &self,
        prefix: impl AsRef<[u8]>,
    )

Source from the content-addressed store, hash-verified

631 /// `revision` (applied index) at scan time. Use `revision` to filter watch events
632 /// during reconnection: skip events where `event.revision <= revision`.
633 pub async fn scan_prefix(
634 &self,
635 prefix: impl AsRef<[u8]>,
636 ) -> ClientApiResult<ScanResult> {
637 let (resp_tx, resp_rx) = MaybeCloneOneshot::new();
638
639 self.cmd_tx
640 .send(d_engine_core::ClientCmd::Scan(
641 Bytes::copy_from_slice(prefix.as_ref()),
642 resp_tx,
643 ))
644 .await
645 .map_err(|_| channel_closed_error())?;
646
647 let result = tokio::time::timeout(self.timeout, resp_rx)
648 .await
649 .map_err(|_| timeout_error(self.timeout))?
650 .map_err(|_| channel_closed_error())?;
651
652 result.map_err(|status| server_error(format!("RPC error: {}", status.message())))
653 }
654
655 /// Internal helper: Get cluster membership via ClusterConf event
656 async fn get_cluster_membership(

Calls 4

channel_closed_errorFunction · 0.85
timeout_errorFunction · 0.85
server_errorFunction · 0.85
sendMethod · 0.80