Expand description
kevy — a single-machine, Redis-compatible key–value server.
This crate is the server: it supplies the command semantics — routing
(KevyCommands) and execution ([dispatch]) — and wires them to the
kevy-rt shared-nothing thread-per-core runtime via serve. The command
logic is also reachable directly (one keyspace, no I/O) through [dispatch],
which is handy for embedding or testing. Built from a small stack of
zero-dependency crates: kevy-sys, kevy-resp, kevy-store, kevy-net,
kevy-rt, kevy-persist.
§Example
Run commands against an in-process keyspace (no sockets):
use kevy::{Argv, KevyCommands, KeyspaceStore};
let kevy = KevyCommands::new();
let mut store = KeyspaceStore::new();
let cmd = |parts: &[&[u8]]| Argv::from(parts.iter().map(|p| p.to_vec()).collect::<Vec<_>>());
assert_eq!(kevy.dispatch(&mut store, &cmd(&[b"SET", b"k", b"v"])), b"+OK\r\n");
assert_eq!(kevy.dispatch(&mut store, &cmd(&[b"GET", b"k"])), b"$1\r\nv\r\n");
assert_eq!(kevy.dispatch(&mut store, &cmd(&[b"INCR", b"n"])), b":1\r\n");To run the full server: serve(config).
Modules§
- verb_
meta - Verb documentation metadata — the single source of truth for COMMAND DOCS, llms.txt, and the MCP schema. Parity tests in tests_verb_meta.rs hold this table and the dispatch surface bidirectionally equal.
Structs§
- Argv
- A parsed command’s argument vector.
- Kevy
Commands - kevy’s command set, plugged into the
kevy-rtruntime: the sharedRuntimeStateplus this shard’s private [ShardCtx]. The runtime clones oneKevyCommandsper shard; the manualCloneshares the state Arc and rebuilds the shard zone empty. - Keyspace
Store - A single-database keyspace.
- Runtime
State - Everything the server knows that is not per-shard keyspace data.
Built once (by
crate::serveor an embedder) and shared across shards behind anArc.
Enums§
- After
Drain - What to do with a connection after draining its buffered commands.
Functions§
- drain_
commands - Parse and dispatch every complete command in
input, appending replies tooutput. Consumes parsed bytes; leaves a trailing partial frame. ReturnsCloseafter aQUITor a protocol error (whose reply is already appended). - handle_
conn - Blocking single-connection handler. Shares command logic with the reactor; retained for tests and simple uses.
- serve
- Run the thread-per-core server forever, entirely shaped by
cfg:cfg.server.threadsshards oncfg.server.bind:cfg.server.port, snapshotting to / restoring fromcfg.server.data_dir, AOF percfg.persistence.aof.threads = 0(the auto sentinel) runs one shard; the CLI resolves auto toavailable_parallelism()before calling in.