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

Function handle_mget

nodedb/src/control/server/resp/handler_kv.rs:185–223  ·  view source on GitHub ↗
(
    cmd: &RespCommand,
    session: &RespSession,
    state: &SharedState,
)

Source from the content-addressed store, hash-verified

183}
184
185pub(super) async fn handle_mget(
186 cmd: &RespCommand,
187 session: &RespSession,
188 state: &SharedState,
189) -> RespValue {
190 if cmd.argc() < 1 {
191 return RespValue::err("ERR wrong number of arguments for 'mget' command");
192 }
193
194 let plan = PhysicalPlan::Kv(KvOp::BatchGet {
195 collection: session.collection.clone(),
196 keys: cmd.args.clone(),
197 });
198
199 match dispatch_kv(state, session, plan).await {
200 Ok(resp) if resp.status == Status::Ok => {
201 let values: Vec<serde_json::Value> =
202 sonic_rs::from_slice(&resp.payload).unwrap_or_default();
203 let items: Vec<RespValue> = values
204 .into_iter()
205 .map(|v| match v {
206 serde_json::Value::String(b64) => {
207 match base64::Engine::decode(
208 &base64::engine::general_purpose::STANDARD,
209 &b64,
210 ) {
211 Ok(data) => RespValue::bulk(data),
212 Err(_) => RespValue::nil(),
213 }
214 }
215 _ => RespValue::nil(),
216 })
217 .collect();
218 RespValue::array(items)
219 }
220 Ok(_) => RespValue::nil_array(),
221 Err(e) => RespValue::err(format!("ERR {e}")),
222 }
223}
224
225pub(super) async fn handle_mset(
226 cmd: &RespCommand,

Callers 1

executeFunction · 0.85

Calls 7

dispatch_kvFunction · 0.85
arrayFunction · 0.85
argcMethod · 0.80
collectMethod · 0.80
errFunction · 0.50
decodeFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected