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

Function execute

nodedb/src/control/server/resp/handler.rs:20–66  ·  view source on GitHub ↗

Execute a RESP command and return the response.

(
    cmd: &RespCommand,
    session: &mut RespSession,
    state: &SharedState,
)

Source from the content-addressed store, hash-verified

18
19/// Execute a RESP command and return the response.
20pub async fn execute(
21 cmd: &RespCommand,
22 session: &mut RespSession,
23 state: &SharedState,
24) -> RespValue {
25 match cmd.name.as_str() {
26 "PING" => handle_ping(cmd),
27 "ECHO" => handle_echo(cmd),
28 "SELECT" => handle_select(cmd, session),
29 "DBSIZE" => handle_dbsize(session, state).await,
30 "GET" => super::handler_kv::handle_get(cmd, session, state).await,
31 "SET" => super::handler_kv::handle_set(cmd, session, state).await,
32 "DEL" => super::handler_kv::handle_del(cmd, session, state).await,
33 "EXISTS" => super::handler_kv::handle_exists(cmd, session, state).await,
34 "MGET" => super::handler_kv::handle_mget(cmd, session, state).await,
35 "MSET" => super::handler_kv::handle_mset(cmd, session, state).await,
36 "INCR" => super::handler_kv::handle_incr(cmd, session, state, 1).await,
37 "DECR" => super::handler_kv::handle_incr(cmd, session, state, -1).await,
38 "INCRBY" => super::handler_kv::handle_incrby(cmd, session, state).await,
39 "DECRBY" => super::handler_kv::handle_decrby(cmd, session, state).await,
40 "INCRBYFLOAT" => super::handler_kv::handle_incrbyfloat(cmd, session, state).await,
41 "GETSET" => super::handler_kv::handle_getset(cmd, session, state).await,
42 "ZADD" => super::handler_sorted::handle_zadd(cmd, session, state).await,
43 "ZREM" => super::handler_sorted::handle_zrem(cmd, session, state).await,
44 "ZRANK" => super::handler_sorted::handle_zrank(cmd, session, state).await,
45 "ZRANGE" => super::handler_sorted::handle_zrange(cmd, session, state).await,
46 "ZCARD" => super::handler_sorted::handle_zcard(session, state).await,
47 "ZSCORE" => super::handler_sorted::handle_zscore(cmd, session, state).await,
48 "EXPIRE" => handle_expire(cmd, session, state, false).await,
49 "PEXPIRE" => handle_expire(cmd, session, state, true).await,
50 "TTL" => handle_ttl(cmd, session, state, false).await,
51 "PTTL" => handle_ttl(cmd, session, state, true).await,
52 "PERSIST" => handle_persist(cmd, session, state).await,
53 "SCAN" => handle_scan(cmd, session, state).await,
54 "KEYS" => handle_keys(cmd, session, state).await,
55 "HGET" => super::handler_hash::handle_hget(cmd, session, state).await,
56 "HMGET" => super::handler_hash::handle_hmget(cmd, session, state).await,
57 "HSET" => super::handler_hash::handle_hset(cmd, session, state).await,
58 "FLUSHDB" => super::handler_hash::handle_flushdb(session, state).await,
59 "AUTH" => handle_auth(cmd, session, state),
60 "PUBLISH" => super::handler_pubsub::handle_publish(cmd, session, state).await,
61 "INFO" => handle_info(cmd, session, state).await,
62 "COMMAND" => RespValue::ok(), // Stub: redis-cli sends COMMAND on connect.
63 "QUIT" => RespValue::ok(),
64 _ => RespValue::err(format!("ERR unknown command '{}'", cmd.name)),
65 }
66}
67
68// ---------------------------------------------------------------------------
69// Simple commands

Callers 1

handle_connectionFunction · 0.70

Calls 15

handle_echoFunction · 0.85
handle_selectFunction · 0.85
handle_dbsizeFunction · 0.85
handle_getFunction · 0.85
handle_delFunction · 0.85
handle_existsFunction · 0.85
handle_mgetFunction · 0.85
handle_msetFunction · 0.85
handle_incrFunction · 0.85
handle_incrbyFunction · 0.85
handle_decrbyFunction · 0.85
handle_incrbyfloatFunction · 0.85

Tested by

no test coverage detected