The Protocol · the foundation
The substrate the
pillars share
The keys, the record, the transitions, and the immutability that make one wire serve three pillars.
Below the language line is the protocol — the part every pillar and every runtime
shares. This chapter teaches it in depth, and it is all real code: the braced
emq:{q}: keyspace that EchoMQ.Keyspace builds; the job
record hash and its field names; the atomic transitions, each one native
command: EchoMQ.Script declares the verb, EchoMQ.Connector sends
it with no Lua, every key carrying its queue's {q} hashtag, and the native
trafikey module, where each core job transition is one EMQ.*
command inside the server, which the same connector sends on wire 6, while lanes, flows and the reaper run only
as scripts; and the immutability and branded-id
discipline — the wire identity each executor fences on, the branded id — that keeps the wire honest. Master this
and the Queue, the Bus, and the Cache are three readings of one substrate.
The wire in four parts
The protocol is four things. The first four modules teach one each; the fifth, the native module, is the second executor of the third part, the transitions. Pick a part to read what it is and the real surface that carries it — then take the module.
The protocol · pick a part
surface: EchoMQ.Keyspace.queue_key/2 → emq:{q}:<type>
the {q} hashtag pins one queue to one Valkey slot; {emq}: is the core reserve
Four parts, one wire: the keys say where, the record says what, the transitions say how — as a script or as a native command — and immutability says it does not change underneath a reader.
The modules
Four modules, each a hub and three dives, then a workshop. Each grounds in real code: the Elixir in
echo/apps/echo_mq and echo/apps/echo_wire — the keyspace
builder, the job record, the script declarations and their one dispatch seam, the branded-id gate and the version fence — and the
native module's Rust handlers in trafikist/crates/trafikey.
The owned keyspace
emq:{q}:<type> built by EchoMQ.Keyspace; the {q} hashtag and the slot it pins; the {emq}: reserve.
The record hash
The job HASH and its field names — state, attempts, payload — part of the protocol; the native module adds two.
Immutability & branded ids
The immutable line, the branded-id gate, and the version fences that guard the wire.
The native module
trafikey: each core job transition one EMQ.* command inside the server, behind a read-only fence; same keys, same fields, and on the ordinary path the same replies.
Workshop
Decode a real key, trace one declaration to its EMQ.* command, and read the retired Lua script beside it.
Redis Patterns Applied
This is the depth behind two Redis Patterns Applied chapters that door here:
R0.3 · Patterns become protocol (the idea that a
pattern, pushed below the language line, becomes a protocol) and
R2 · Coordination (hash-tag co-location and one-slot atomic Lua — the
{q} keyspace this chapter owns). There the pattern is the door; here is the wire.
Up next — the three pillars
With the protocol in hand, take the pillar you need. Each is a reading of this substrate: the Queue distributes work over it, the Bus broadcasts signals across it, the Cache serves reads in front of it.
The Queue
Distribute work: lifecycle, lanes, batches, controls, flows.
The Bus
Broadcast signals: events, the event log, consumer groups, time-travel.
The Cache
Serve reads: cache-aside, single-flight, coherence on the Bus.
Back to the Overview
The thesis, the three pillars, and the door.
After the pillars, the Proof chapter shows the whole system holds: the conformance suite, telemetry and the read plane.
References
Sources
- Valkey — Documentation — the store the keyspace, the record, and the transitions run inside — the substrate of record.
- Valkey — HSET — the hash write the record is built from.
- Redis — EVALSHA — the retired load-once, run-by-SHA dispatch the Lua scripts used; the connector refuses it today.
- Valkey — Modules Introduction — how a module registers its own commands inside the server, as
trafikeyregisters theEMQ.*transitions. - Valkey — Cluster specification — the
{hashtag}→hash-slot routing the per-queue-hashtag keyspace is built for: every key of a queue on one slot, where a multi-key script is legal. - llmstxt.org — The llms.txt convention — the machine-readable map format the course follows.
Related in this course
- Overview — the chapter that frames the system.
- The protocol below the line — the orientation dive this chapter deepens.
- redis-patterns R2 · Coordination — hash-tag co-location, the near side of the door.
- The Branded Component System — the architecture the wire belongs to.