PING and ECHO
Dispatch commands case-insensitively and serialize exact RESP replies.
PING and ECHO
Dispatch commands case-insensitively and serialize exact RESP replies. Keep commands added earlier compatible.
Observable contract
The harness reads JSON; raw RESP values are escaped inside strings. The same parser and executor should later be usable with a real socket.
{ "op": "execute", "commands": [["PING"], ["ECHO", "hola"]] }
produces:
{ "replies": ["+PONG\r\n", "$4\r\nhola\r\n"] }
Emit compact JSON with a final newline. An invalid request leaves stdout empty, writes error to stderr, and exits non-zero.
Implementation
Separate the incremental RESP parser, command dispatch, store, and serialization. RESP sizes count bytes. Every client needs its own input buffer and transaction state; the data dictionary must never hold a half-built reply.
Test fragmentation at every byte, null values, wrong arity, and mixed command casing. Whenever time is involved, use only the clock supplied by the harness.
Acceptance criteria
- The example produces the exact response.
- A failed command does not corrupt data.
- Collections and snapshots use deterministic ordering.