jonnify·redis /redis-patterns/overview/patterns-become-protocol

R0.3 · Overview — module hub

Patterns become protocol.

A handful of Redis patterns, owned the right way, stop being one library’s habits and become a protocol the bus itself declares: a closed key grammar, a three-field job hash, four sorted sets, eight verbs over six scripts — versioned, fenced, and backed by Valkey.

Grounding: content/bcs3.1.md · bcs3.2.md · bcs3.3.md · bcsA.md · docs/echo_mq/emq.design.md — every figure verbatim from a committed record.

The machine as five layers. Select a layer to read its scope and whether it belongs to the owned protocol.
L4 · runtime API L3 · the connector — the boundary · held by the version fence — L2 · the bundle L1 · the grammar L0 · Valkey
readout · Select a layer. L1 and L2 are the owned protocol; L3 and L4 are each runtime’s own; L0 is the engine, gated.

Static verdicts — L4 runtime API → varies per runtime · L3 connector → varies per runtime, gated PASS 8/8 · L2 bundle → owned, versioned behind the fence · L1 grammar → owned, versioned behind the fence · L0 Valkey → external, an enforced conformance gate.

§1

From patterns to an owned protocol

emq.md · bcs3.1–3.3

A protocol here is not a network wire format. It is a declared Redis data convention joined to a set of atomic Lua scripts — a written agreement about which key holds which structure, what the row’s fields are, and which script makes each state change. EchoMQ owns that agreement outright. The grammar is closed: every per-queue key parses as emq:{q}:<type>, the job position is gated to branded ids, and the braced {emq}: reserve holds the deployment’s own facts.

The job row is a hash of exactly three fields — state, attempts, payload — and deliberately nothing more: no enqueued_at, because mint time already lives inside the id. Four sorted sets carry the lifecycle — pending (score-zero), active (lease-scored), schedule (run-at-scored), dead — and eight verbs over six scripts move work between them. R0.2 fixed where Redis sits in the BCS build; this module answers why the worked examples hold for any runtime that connects: the patterns are not language code. They are the bus’s owned protocol.

§2

The boundary is a fence, not a pin

bcs3.1 F3 · bcsA · verbatim

The boundary between L2 and L3 is the line between the owned protocol and the runtime’s own code. What holds the line is not a pinned commit. It is the version fence: at every connect — first boot and every reconnect — the connector reads {emq}:version, claims it on a fresh keyspace, and refuses any other value with a typed error. The committed line reads: GET {emq}:version answers echomq:2.0.0 through the fenced connector itself.

L4  runtime API     — varies per runtime: EchoMQ.Jobs in Elixir; a Go loop around the same calls
L3  the connector   — varies per runtime: RESP, pipelining, EVALSHA-first dispatch
——— the boundary — held by the version fence: a mismatch is a typed boot refusal ———
L2  the bundle      # six Lua scripts, eight verbs; every key declared or root-derived
L1  the grammar     # emq:{q}:<type> · the three-field hash · the four sorted sets
L0  Valkey    # the engine — external, and an enforced conformance gate
the application · the connector that holds the boundary

Gated against live Valkey

The fence, the declared-keys dispatch, and the pipeline discipline are not aspirations — the connector’s gate record is committed, figure by figure.

content/bcsA.md · the EchoMQ connector gate, against live Valkeyfrozen
fence claimed                 echomq:2.0.0   ← typed, fatal on mismatch
pipelined EVALSHA             161192 ops/s   ← declared-keys law at speed
script_loads                  1              ← exactly one NOSCRIPT load
gate record                   PASS 8/8
§3

The three dives

the layers → the owned core → the door

Each dive takes one part of the story. Read them in order — the four layers start.

the pattern

Take the patterns a queue needs — atomic moves, leases, schedules, a morgue — write them down as a grammar plus scripts, version the result, and fence the boot.

its EchoMQ application

The closed emq:{q}:<type> grammar, the three-field hash, the four sorted sets, eight verbs over six scripts — owned, versioned, and backed by Valkey.

No upstream pin holds this protocol together. A closed grammar, a versioned bundle, and a two-way fence do — and after R0.3 the Overview chapter is complete and the pattern chapters begin.

§4

References

sources · related

Sources

Related in this course