Expand description
Replication handshake — the first round-trip a replica makes against the primary’s replication TCP listener.
Wire shape:
- Replica → primary: a RESP2 multi-bulk command
REPLICATE FROM <from-offset> ID <replica-id>(5 args). The<from-offset>is0for a fresh replica (full-sync intent) or the last applied offset from a reconnecting replica. - Primary → replica: a RESP2 simple string
+ACK <current-offset>, where<current-offset>is the primary’snext_offsetat the moment of ack. The replica records it and starts consuming live frames; if the primary’scrate::source::ReplicationSourcecannot serve from<from-offset>(TooOld), the primary instead begins a snapshot ship (handled by the wiring layer, not here).
This module owns only the parse + format primitives. Socket I/O, retry, and “did the primary choose snapshot vs live stream” logic live in the future replication source/replica modules.
Structs§
- Handshake
Req - Parsed
REPLICATE FROM <from-offset> ID <replica-id>request.
Enums§
- Handshake
Error - Why a
parse_replicate_fromcall rejected its input.
Functions§
- encode_
ack - Encode the primary’s
+ACK <current-offset>\r\nresponse. - parse_
replicate_ from - Parse a
REPLICATE FROM <offset> ID <id>command from an already-decodedArgv(the caller has run the bytes throughkevy_resp::parse_command_intofirst).