B3 · The Bus — manuscript Part III
The law, set in motion.
Part I gave every row a name and Part II gave the names a home; Part III puts them in
motion. EchoMQ 2.0 is the manuscript's bus — built Valkey-native from the first byte: a fresh
emq: keyspace, a version-fenced Lua bundle negotiated before any command runs, and no
compatibility ballast from any predecessor wire.
The cargo law is the series' oldest — only identities cross. A job names the entities it concerns; it never carries their rows, and everything the queue does moves fourteen-byte names whose bytes are already chronology. Each module below teaches one written chapter, its committed rung quoted verbatim on the page.
The seven modules
content/bcs3.1.md – bcs3.6.md, bcsA.mdThe Fence and the Keyspace
The connector substrate as the part's vocabulary: the emq:{q}:<type> grammar, the
braced {emq}: base reserved for deployment facts, the boot fence as queue-grade gating,
and the co-location law. The rung reads PASS 5/5.
Jobs Are Entities
The JOB kind registered under the D-8 bar; the three-field row, state /
attempts / payload and nothing more; enqueue as one idempotent script; the
order theorem's browse dividend. The rung reads PASS 5/5.
The State Machine in Lua
Claim, complete, retry, and dead-letter, every transition a single script. The server clock owns
leases; attempts is the fencing token; the morgue keeps the last error and the reaper runs
on the clock. The rung reads PASS 6/6.
Fair Lanes
Per-group lanes and a ring that holds exactly the serviceable ones; the rotating claim; ceilings and
pauses; park-don't-poll on a wake key. Rotation is the refusal, with starvation gated, not promised.
The rung reads PASS 8/8.
The Bus Meets the Stores
Commands out of entities, results back into properties, ids the only cargo. A row that records the
names it has absorbed turns at-least-once delivery into exactly-once effect; the consumer is one more
owner in the Part II tree. The rung reads PASS 6/6.
Conformance and the Rival's Numbers
Fourteen wire-level contracts a port drives verbatim, the referee habit, and Oban 2.18.3 on
PostgreSQL 16.14 measured with the asymmetry stated first. The rung reads PASS 6/6, and
CONFORMANCE 14/14.
Appendix A — The Connector
The substrate the part stands on: one-pass RESP2, pipelining as the primitive, the typed fatal
fence, EVALSHA-first declared-keys scripts, and the measured wire. The gate reads PASS 8/8
against live Valkey.
A module card becomes a link when its pages ship; the dives per module are fixed in the chapter spec, and the reading order is the arc above. Part III is fully written — all seven modules are buildable, with a frozen rung behind each.
The laws of the part
content/bcs3.mdPart III states six laws and holds every chapter to them. They are the manuscript's, named here so the modules below read as applications of a rule rather than a list of features.
One transition, one script
Every job state change — enqueue, claim, complete, retry, dead-letter — is a single
EVALSHA against the versioned bundle. Partial states are unrepresentable: no wire sequence
exists that could produce one.
The fence before the first command
The echomq:2.0.0 handshake runs at connect and at every reconnect; a bundle-version
mismatch is a typed refusal at boot, never a degraded session. Wrong-kind servers are refused the way
wrong-kind ids are.
Jobs are entities
Chapter 3.2 registers JOB under the D-8 bar — jobs are minted, gated, paged, and
audited like any kind, and the order theorem gives queue browsing for free because job ids sort by
submission.
Park, don't poll
Idle consumers block on keys and cost nothing; readiness arrives as a wake, not a discovered flag. Fairness across groups is constructed — round-robin lanes by assignment — never hashed.
Delivery semantics, named per surface
At-least-once is stated where it holds and made cheap to honor: enqueue is idempotent by job id, and checkpoints survive consumer crashes so a redelivery resumes instead of repeating.
Rivals measured with advantages printed
The closing chapter benchmarks against the transactional-enqueue class. Oban's same-transaction enqueue is a real advantage, and its number appears beside the bus's — a gate that hides the rival's win is decoration.
The floor under the floor
committed outputs, quoted verbatimPart III is fully written, and every chapter lands with a rung — an executable check and a frozen transcript, committed beside the prose. The course inherits the ethic: a number that is not in a committed output does not appear on a page. The six chapter rungs, the conformance record, and the connector gate on file:
bcs_rung_3_1_check.out the fence and the keyspace PASS 5/5 bcs_rung_3_2_check.out jobs are entities PASS 5/5 bcs_rung_3_3_check.out the state machine in Lua PASS 6/6 bcs_rung_3_4_check.out fair lanes PASS 8/8 bcs_rung_3_5_check.out the bus meets the stores PASS 6/6 bcs_rung_3_6_check.out conformance and the rival PASS 6/6 CONFORMANCE 14/14 emq_connector_check.out the connector (Appendix A) PASS 8/8
The connector gate ran against live Valkey; the conformance bench measured the bus against Oban 2.18.3 on PostgreSQL 16.14, with the asymmetry stated before the first ratio — the rival's enqueue is durable and transactional, the bus's is volatile by Decision D-2. What the part will not do is stated too: no Streams or PubSub (EMQ 3.0 by Decision D-3), and no cluster routing — the slot function is committed and parked, single-instance Valkey the stated topology.
Up next
built as the manuscript shipsEchoCache
Part IV — the near-cache: declared L1 tables, single-flight fills, coherence by mint time, the single-writer ring, and the lane that replays. The manuscript is written through its fourth chapter.
Go, Node, Fly, Trading
Parts V–VIII — the Go and Node runtimes, production on Fly, and the trading capstone. The manuscript plans these chapters; the course builds them as the book ships.
The Elixir BCS Core
Part II — the stores Part III puts in motion: a system as an OTP application, property stores on ETS, the CHAMP forest, archetypes as data, relations as systems.
The doors
the sibling coursesEchoMQ — the protocol, in depth
The bus B3 narrates, taught rung by rung: the keyspace, the Lua inventory, conformance on Valkey.
/redis-patternsRedis Patterns Applied
The substrate patterns under the bus: sorted sets, atomic Lua moves, list rotation, blocking pops.
/elixirFunctional Programming in Elixir
The Portal engine, and the umbrella where echo_data — the production identity library — lives.
References
sources · relatedSources
- Valkey — the RESP protocolthe wire EchoMQ is built on: length-prefixed bulk strings, inline replies, error values
- Valkey — programmabilityatomic script execution, the basis of one-transition-one-script
- Valkey 8.1.0 GAthe substrate the connector gate and the conformance bench measured against (Valkey)
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- B2 — The Elixir BCS Corethe stores Part III puts in motion
- EchoMQ — the coursethe far side of the B3 door, the bus in rung-level depth
- Redis Patterns Appliedthe substrate patterns under the bus
- Functional Programming in Elixirthe umbrella where echo_data lives