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

Method get_multi_with_consistency

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

Advanced: Get multiple keys with explicit consistency policy.

(
        &self,
        keys: &[Bytes],
        consistency: ReadConsistencyPolicy,
    )

Source from the content-addressed store, hash-verified

360
361 /// Advanced: Get multiple keys with explicit consistency policy.
362 pub async fn get_multi_with_consistency(
363 &self,
364 keys: &[Bytes],
365 consistency: ReadConsistencyPolicy,
366 ) -> ClientApiResult<Vec<Option<Bytes>>> {
367 let request = ClientReadRequest {
368 client_id: self.client_id,
369 keys: keys.to_vec(),
370 consistency_policy: Some(consistency),
371 };
372
373 let (resp_tx, resp_rx) = MaybeCloneOneshot::new();
374
375 self.cmd_tx
376 .send(d_engine_core::ClientCmd::Read(request, resp_tx))
377 .await
378 .map_err(|_| channel_closed_error())?;
379
380 let result = tokio::time::timeout(self.timeout, resp_rx)
381 .await
382 .map_err(|_| timeout_error(self.timeout))?
383 .map_err(|_| channel_closed_error())?;
384
385 let response =
386 result.map_err(|status| server_error(format!("RPC error: {}", status.message())))?;
387
388 if response.error != ErrorCode::Success {
389 return Err(Self::map_error_response(
390 response.error,
391 response.leader_hint,
392 response.retry_after_ms,
393 ));
394 }
395
396 let read_results = extract_read_payload(response.result)?;
397 // Reconstruct result vector in requested key order.
398 // Server only returns results for keys that exist, so we must
399 // map by key to preserve positional correspondence with input.
400 let results_by_key: std::collections::HashMap<_, _> =
401 read_results.entries.into_iter().map(|e| (e.key, e.value)).collect();
402 Ok(keys.iter().map(|k| results_by_key.get(k).cloned()).collect())
403 }
404
405 /// Delete a key-value pair with strong consistency.
406 ///

Callers 3

get_multi_eventualMethod · 0.80
get_multi_with_policyMethod · 0.80

Calls 6

channel_closed_errorFunction · 0.85
timeout_errorFunction · 0.85
server_errorFunction · 0.85
extract_read_payloadFunction · 0.85
sendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected