Skip to content

Commit

Permalink
Merge pull request #15 from liftbridge-io/msg_type
Browse files Browse the repository at this point in the history
Update protocol
  • Loading branch information
tylertreat authored Feb 27, 2020
2 parents 8382298 + 114e77e commit ecf2163
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ with the following header and be encoded as a `Message` (defined in

### Liftbridge Envelope Header

All Liftbridge messages and RPCs sent over NATS are prefixed with an envelope
header. This includes client-facing messages, such as publishes and acks, as
well as internal RPCs like replication.

```
0 8 16 24 32
├───────────────┴───────────────┴───────────────┴───────────────┤
│ Magic Number │
├───────────────┬───────────────┬───────────────┬───────────────┤
│ Version │ HeaderLen │ Flags │ Reserved
│ Version │ HeaderLen │ Flags │ MsgType
├───────────────┴───────────────┴───────────────┴───────────────┤
│ CRC-32C (optional) │
└───────────────────────────────────────────────────────────────┘
Expand All @@ -45,6 +49,8 @@ bumped if the envelope format changes or if the message encoding changes in a
non-backwards-compatible way. Adding fields to the messages should not require
a version bump.

Currently, the only supported protocol version is v0, i.e. `0x00`.

#### HeaderLen [1 byte]

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

| Bit | Description |
| --- | --------------- |
| :-- | :-------------- |
| 0 | CRC-32C enabled |

#### MsgType [1 byte]

This is the Liftbridge-specific message type the envelope contains:

| MsgType | Name | Description | Internal |
| :------ | :------------------------ | :----------------------------------------------------- | :------- |
| 0 | Publish | Client-published message | no |
| 1 | Ack | Server-published ack | no |
| 2 | ReplicationRequest | Request to replicate partition data | yes |
| 3 | ReplicationResponse | Response to ReplicationRequest | yes |
| 4 | RaftJoinRequest | Request to join Raft cluster | yes |
| 5 | RaftJoinResponse | Response to RaftJoinRequest | yes |
| 6 | LeaderEpochOffsetRequest | Request for partition leader's latest offset for epoch | yes |
| 7 | LeaderEpochOffsetResponse | Response to LeaderEpochOffsetRequest | yes |
| 8 | PropagatedRequest | Request forwarded to metadata leader | yes |
| 9 | PropagatedResponse | Response to PropagatedRequest | yes |
| 10 | ServerInfoRequest | Request for cluster information | yes |
| 11 | ServerInfoResponse | Response to ServerInfoRequest | yes |
| 12 | PartitionStatusRequest | Request to get partition status | yes |
| 13 | PartitionStatusResponse | Response to PartitionStatusRequest | yes |
| 14 | PartitionNotification | Signal new data is available for partition | yes |

#### CRC-32C [4 bytes, optional]

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

0 comments on commit ecf2163

Please sign in to comment.