ZeroMQ Protocol
Goal
Turn a ZeroMQ topology into a small, explicit, evolvable wire contract with bounded flow control and testable peer state.
Workflow
- Write the protocol before hiding it inside code.
- State goals, roles, transport assumptions, version/maturity, security, and exact failure semantics.
- Define message grammar and frame/field types; use normative MUST/SHOULD/MAY intentionally.
- Keep implementation internals out of the wire model.
- Split low-volume control from high-volume data when their needs differ:
- control: descriptive, extensible, synchronous errors are normal;
- data: compact, async, stable, exceptional errors are fatal/drop/recover.
- Model non-trivial peer conversations as finite state machines.
- Add protocol signatures/version fields where endpoints can receive stale or unrelated traffic.
- For bulk transfer, use receiver-issued byte/message credits instead of unbounded sender queues.
- Cross-test independent client/server implementations and malformed inputs.
- Version contracts compatibly; never repurpose old names with new meaning.
Rules
- Code is an implementation, not the only specification.
- Multipart framing is atomic but not a substitute for semantic versioning.
- Measure before choosing a custom binary codec.
- Make parsers bounded and reject impossible sizes/states before allocation.
- Recovery state should travel with the client/request when that avoids fragile server-held sessions.