jonnifyechomq

The Queue · module 03

Batches

A batch is not a new kind of work. It is the same per-item contract — pipelined.

To admit many jobs is to run the @enqueue transition many times in one wire flush; to compose many flows is to land each through the single add/3, fail-closed per flow; to checkpoint many leases is to re-score every active member under one server-clock read. Each bulk verb is the bulk twin of a single verb taught elsewhere, and each answers one verdict per item, in input order. Batching changes the round-trip count, never the rule each item obeys. Pick a verb below, then take the three dives.

Three bulk verbs, one rule

Three verbs on the real Queue surface admit, compose, and extend many at once. Each is the bulk twin of a single verb, each saves round trips, and each keeps the single verb's contract. Pick a verb to read its handle, the single verb it batches, its wire shape, and the shape it returns — the readout is a pure function of the verb chosen.

The bulk verbs · pick one

enqueue_manyadmit many add_bulkcompose many extend_locksextend many one Valkey · one verdict per item, in input order

Each bulk verb is the bulk twin of a single verb: it saves round trips and keeps the contract. A batch is a wire optimization, not a semantic one.

The dives

Three dives read the bulk verbs in depth, each grounded in real echo/apps/echo_mq code: admitting many in one flush, composing many flows fail-closed per flow, and extending many leases under one clock read.

built page ready to read

Pattern & implementation

Where Redis Patterns Applied teaches pipelining — many commands in one round trip, replies in order — this module is where the move lands across three verbs.

the pattern (Redis Patterns Applied)

Pipelining sends many commands in one round trip and reads the replies in order, so N operations cost one network turn instead of N. Reliable queues is the near side of the door.

the implementation (echo_mq)

EchoMQ.Jobs.enqueue_many/3 loads @enqueue once and pipelines the EVALSHA calls; EchoMQ.Flows.add_bulk/3 issues add/3 per flow; EchoMQ.Jobs.extend_locks/4 re-scores every matching member in one script — each keeping the single verb's contract.

Take the dives in order, or jump to batch lease extension if you already know admission. The next module in The Queue covers the control plane beyond enqueue and claim.

References

Sources

Related in this course