R0.3.3 · Patterns become protocol — dive 3
The door to EchoMQ.
An owned protocol buys one thing: any runtime that loads the same scripts against the same grammar speaks the same bus. No port, no shared codebase — a contract: the script is the contract, the branded id is the wire form, and one queue answers one slot by grammar.
Grounding: content/bcs3.2.md (the script is the contract) · bcs3.3.md (the Go consumer loop) · bcs3.1.md + bcsA.md (the slot figures) · docs/echo_mq/emq.design.md (the wire form, the ladder statuses).
Static verdict — the same source string yields the same SHA1, and any client on any runtime that loads it speaks identical semantics (bcs3.2). The Elixir runtime is the committed reference; the Go consumer is a loop around the same EVALSHA calls (bcs3.3).
The script is the contract; the id is the wire form
content/bcs3.2.md · bcs3.3.md · emq.mdThe cross-runtime story needs no port at all. The six scripts are the contract: the same source string
yields the same SHA1, and any client on any runtime that loads it speaks identical semantics — the
same pop, the same token mint, the same lease arithmetic. A producer in Elixir runs enqueue;
a consumer in Go is a loop around the same EVALSHA calls:
id, payload, token, ok := claim(conn, q, lease)
if !ok { time.Sleep(idle); continue }
if err := work(payload); err != nil {
retry(conn, q, id, token, backoff(attempt), maxAttempts, err.Error())
} else {
complete(conn, q, id, token)
}
The second clause makes the data legible everywhere: the branded form is the wire form. Job ids are branded Snowflakes — three-letter namespace, base62 body, fourteen bytes — and they appear as themselves in keys, set members, and payloads. Byte order is mint order, so any runtime browses newest-first from the bytes alone, and the decimal rendering stays internal arithmetic.
One queue, one slot, by grammar
content/bcs3.1.md F5 · bcsAThe third clause is spatial. The hashtag is the queue name, so every key of one queue answers one cluster slot. The consequence is the part’s future: every per-queue transition script is single-slot legal by grammar, so the clustered day needs no wire change — and cross-queue choreography goes through the application, never through a multi-queue script.
pending, active, meta, and the job row of {orders} all answer slot 105; {fills} answers 4165
Static verdicts — {orders} → slot 105 · {fills} → 4165 · the payments queue → 8507 · the CRC16 specification vector → 12739 holds.
Notes on ValkeyHash tags exist to ensure that multiple keys are allocated in the same hash slot — CRC16 modulo 16384 over the tag — valkey.io/topics/cluster-spec.
The placement — the bus and the near-cache
the BCS build · bcs4 abstractsIn the BCS build the contract has an address. EchoMQ is the bus: the queue patterns of this course — atomic moves, leases, schedules, the morgue — live in its bundle, backed by Valkey under the hood. EchoStore is the near-cache in front: branded keys, local speed, bus-driven coherence — an L1 of ETS tables over the shared L2 Valkey. The cache family of this course lands in EchoStore; the queue, coordination, time, and flow families land in the bus. One engine, two surfaces, and the patterns of the catalog map onto them chapter by chapter.
A shared, written-down contract makes two systems interoperate without shared code — the agreement is the artifact, not the codebase.
The scripts, the branded wire form, and the slot-by-grammar law — an Elixir producer and a Go consumer share one queue because both load the same bytes.
The doors
live routes · living statusThis is where the module hands off — and the doors are real routes now.
EchoMQ — the protocol, in depth
The grammar, the bundle, the fence, conformance on Valkey — taught rung by rung. Living status: emq.1 built · emq.2 specced · emq.3–5 drafted · emq.6 specced.
/bcsThe Branded Component System
The architecture the bus and the near-cache are built inside — every figure from a frozen transcript.
/elixirFunctional Programming in Elixir
The functional-Elixir craft, and the echo umbrella where the EchoMQ reference runtime lives.
A contract you can read is a door you can walk through. With this dive the Overview chapter closes, and the pattern chapters begin.
References
sources · relatedSources
- Valkey — Cluster specification — hash slots, CRC16 modulo 16384, and hash tags as the same-slot mechanism.
- Valkey — Programmability — scripts cached by SHA1; the dispatch the contract rides.
- Redis — Documentation — the shared store the runtimes read and write through the grammar.
- llmstxt.org — The llms.txt convention — the machine-readable maps this course and the EchoMQ course publish.
Related in this course
- R0.3 · Patterns become protocolthe module hub — the pager loops back here
- R0.3.2 · The immutable corethe core this contract rides on
- R0.2 · Valkey under codemojexwhere Valkey sits in the build
- /echomqthe far side of this door
- /bcsthe architecture, with the frozen transcripts