jonnifyechomq

The Protocol · module 04

What holds the
wire together

The keys are fixed, the ids are branded, and a connection that does not match the wire is refused.

The keyspace says where, the record says what, the scripts say how. This module teaches what keeps all three honest over time. Three guards do it: the immutable line — the keys and field names are fixed, so the layer below the line does not change underneath a reader; the branded-id gate — a job id is a 14-byte branded Snowflake under JOB, checked in Lua before a row is written; and the version fence — the reserved {emq}:version key the connector claims or verifies before its first command. All real code, grounded in echo/apps/echo_mq and echo/apps/echo_wire.

The three guards

Three things hold the wire together, and the three dives of this module are each one of them. Pick a guard to read what it protects and the real surface that carries it — then take the dive.

What holds the wire · pick a guard

immutable linekeys + fields fixed branded-id gateJOB-namespaced version fence{emq}:version one Valkey · emq:{q}:*

Three guards, one wire: the line keeps the substrate from shifting, the gate keeps a stranger's id out, and the fence keeps a mismatched connection from ever touching the store.

The dives

Three dives, each one guard. Each grounds in the real echo/apps/echo_mq and echo/apps/echo_wire code — the keyspace builder, the @enqueue gate, and the connector's fence.

built page ready to read

Redis Patterns Applied

This is the depth behind R2 · Coordination in Redis Patterns Applied: the branded-key and atomic check-then-act patterns — atomic updates and the one-slot move — are exactly what the @enqueue gate and the SET … NX fence apply. There the pattern is the door; here is the wire it guards.

Up next

This is the last module of the Protocol chapter. Close it in the workshop, or step back to the chapter to take the keyspace, the record, and the Lua layer in any order.

References

Sources

Related in this course