jonnify·redis /redis-patterns/overview/patterns-become-protocol/the-door-to-echomq

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).

Produce here, consume there. Pick a producer and a consumer; the readout traces the job through the shared contract. Hover a node in the diagram to read its part.
Elixir · reference runtime Go · consumer loop one Valkey · the shared store
readout · Elixir runs enqueue — the three-field row lands and the id joins pending, atomically. Go claims — ZPOPMIN, HINCRBY attempts, the lease on the server’s clock — then completes with the token. Same bytes, same SHA1, same semantics.

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).

§1

The script is the contract; the id is the wire form

content/bcs3.2.md · bcs3.3.md · emq.md

The 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:

content/bcs3.3.md · the Go consumer loop · verbatimfrozen
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.

§2

One queue, one slot, by grammar

content/bcs3.1.md F5 · bcsA

The 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.

content/bcs3.1.md · the co-location law · committed linefrozen
pending, active, meta, and the job row of {orders} all answer slot 105; {fills} answers 4165
The slot, computed. Pick a queue — by button or by hovering its column; the readout answers with its committed slot figure. The vector row asserts the CRC16 itself.
emq:{orders}:* slot 105 emq:{fills}:* slot 4165 the payments queue slot 8507 client-side CRC16 mod 16384 · vector 12739
readout · Pick a queue. Every key of one queue answers one slot — the figures are committed, not computed here.

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.

§3

The placement — the bus and the near-cache

the BCS build · bcs4 abstracts

In 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.

the pattern

A shared, written-down contract makes two systems interoperate without shared code — the agreement is the artifact, not the codebase.

its EchoMQ application

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.

§4

The doors

live routes · living status

This is where the module hands off — and the doors are real routes now.

A contract you can read is a door you can walk through. With this dive the Overview chapter closes, and the pattern chapters begin.

§5

References

sources · related

Sources

Related in this course