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

Function handle_put

nodedb-cluster/src/distributed_array/handler.rs:105–128  ·  view source on GitHub ↗
(
    local_vshard_id: u32,
    payload: &[u8],
    executor: &Arc<dyn ArrayLocalExecutor>,
)

Source from the content-addressed store, hash-verified

103}
104
105async fn handle_put(
106 local_vshard_id: u32,
107 payload: &[u8],
108 executor: &Arc<dyn ArrayLocalExecutor>,
109) -> Result<Vec<u8>> {
110 let req: ArrayShardPutReq =
111 zerompk::from_msgpack(payload).map_err(|e| ClusterError::Codec {
112 detail: format!("ArrayShardPutReq decode: {e}"),
113 })?;
114
115 // Validate routing before dispatching: the PUT must have been sent to
116 // the correct shard. A mismatch means the coordinator used a stale
117 // routing table and the write must be rejected so the caller can retry
118 // with a refreshed routing table rather than silently writing to the
119 // wrong shard.
120 validate_put_routing(&req, local_vshard_id)?;
121
122 let applied_lsn = executor.exec_put(&req).await?;
123 let resp = ArrayShardPutResp {
124 shard_id: local_vshard_id,
125 applied_lsn,
126 };
127 serialise(resp)
128}
129
130async fn handle_delete(
131 local_vshard_id: u32,

Callers 1

handle_array_shard_rpcFunction · 0.85

Calls 3

validate_put_routingFunction · 0.85
serialiseFunction · 0.85
exec_putMethod · 0.45

Tested by

no test coverage detected