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

Method delete

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

Delete a key-value pair with strong consistency. # Errors Returns an error if the node is not the leader, the channel is closed, the operation times out, or the state machine returns a server error.

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

Source from the content-addressed store, hash-verified

408 /// Returns an error if the node is not the leader, the channel is closed,
409 /// the operation times out, or the state machine returns a server error.
410 pub async fn delete(
411 &self,
412 key: impl AsRef<[u8]>,
413 ) -> ClientApiResult<()> {
414 let request = ClientWriteRequest {
415 client_id: self.client_id,
416 command: Some(WriteOperation::Delete {
417 key: Bytes::copy_from_slice(key.as_ref()),
418 }),
419 };
420
421 let (resp_tx, resp_rx) = MaybeCloneOneshot::new();
422
423 self.cmd_tx
424 .send(d_engine_core::ClientCmd::Propose(request, resp_tx))
425 .await
426 .map_err(|_| channel_closed_error())?;
427
428 let result = tokio::time::timeout(self.timeout, resp_rx)
429 .await
430 .map_err(|_| timeout_error(self.timeout))?
431 .map_err(|_| channel_closed_error())?;
432
433 let response =
434 result.map_err(|status| server_error(format!("RPC error: {}", status.message())))?;
435
436 if response.error != ErrorCode::Success {
437 return Err(Self::map_error_response(
438 response.error,
439 response.leader_hint,
440 response.retry_after_ms,
441 ));
442 }
443
444 Ok(())
445 }
446
447 /// Returns the client ID assigned to this local client
448 pub fn client_id(&self) -> u32 {

Calls 4

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