Skip to content

Commit ecf2163

Browse files
authored
Merge pull request #15 from liftbridge-io/msg_type
Update protocol
2 parents 8382298 + 114e77e commit ecf2163

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ with the following header and be encoded as a `Message` (defined in
2121

2222
### Liftbridge Envelope Header
2323

24+
All Liftbridge messages and RPCs sent over NATS are prefixed with an envelope
25+
header. This includes client-facing messages, such as publishes and acks, as
26+
well as internal RPCs like replication.
27+
2428
```
2529
0 8 16 24 32
2630
├───────────────┴───────────────┴───────────────┴───────────────┤
2731
│ Magic Number │
2832
├───────────────┬───────────────┬───────────────┬───────────────┤
29-
│ Version │ HeaderLen │ Flags │ Reserved
33+
│ Version │ HeaderLen │ Flags │ MsgType
3034
├───────────────┴───────────────┴───────────────┴───────────────┤
3135
│ CRC-32C (optional) │
3236
└───────────────────────────────────────────────────────────────┘
@@ -45,6 +49,8 @@ bumped if the envelope format changes or if the message encoding changes in a
4549
non-backwards-compatible way. Adding fields to the messages should not require
4650
a version bump.
4751

52+
Currently, the only supported protocol version is v0, i.e. `0x00`.
53+
4854
#### HeaderLen [1 byte]
4955

5056
The header length is the offset of the payload. This is included primarily for
@@ -55,9 +61,31 @@ safety.
5561
The flag bits are defined as follows:
5662

5763
| Bit | Description |
58-
| --- | --------------- |
64+
| :-- | :-------------- |
5965
| 0 | CRC-32C enabled |
6066

67+
#### MsgType [1 byte]
68+
69+
This is the Liftbridge-specific message type the envelope contains:
70+
71+
| MsgType | Name | Description | Internal |
72+
| :------ | :------------------------ | :----------------------------------------------------- | :------- |
73+
| 0 | Publish | Client-published message | no |
74+
| 1 | Ack | Server-published ack | no |
75+
| 2 | ReplicationRequest | Request to replicate partition data | yes |
76+
| 3 | ReplicationResponse | Response to ReplicationRequest | yes |
77+
| 4 | RaftJoinRequest | Request to join Raft cluster | yes |
78+
| 5 | RaftJoinResponse | Response to RaftJoinRequest | yes |
79+
| 6 | LeaderEpochOffsetRequest | Request for partition leader's latest offset for epoch | yes |
80+
| 7 | LeaderEpochOffsetResponse | Response to LeaderEpochOffsetRequest | yes |
81+
| 8 | PropagatedRequest | Request forwarded to metadata leader | yes |
82+
| 9 | PropagatedResponse | Response to PropagatedRequest | yes |
83+
| 10 | ServerInfoRequest | Request for cluster information | yes |
84+
| 11 | ServerInfoResponse | Response to ServerInfoRequest | yes |
85+
| 12 | PartitionStatusRequest | Request to get partition status | yes |
86+
| 13 | PartitionStatusResponse | Response to PartitionStatusRequest | yes |
87+
| 14 | PartitionNotification | Signal new data is available for partition | yes |
88+
6189
#### CRC-32C [4 bytes, optional]
6290

6391
The CRC-32C (Castagnoli) is the checksum of the payload (i.e. from HeaderLen to

0 commit comments

Comments
 (0)