Documentation
¶
Overview ¶
Package batch implements the canonical message batch record shared by produce request bodies and poll reply bodies: a 256-byte batch header followed by message frames of [48-byte header][payload][user headers].
Index ¶
Constants ¶
const HeaderSize = 256
HeaderSize is the size of the batch header. Bytes past the declared fields are reserved and stay zero.
const MessageHeaderSize = 48
MessageHeaderSize is the size of a message frame header.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct {
PartitionId uint64
BaseOffset uint64
BaseTimestamp uint64
OriginTimestamp uint64
BatchLength uint64
BatchChecksum uint64
MessageCount uint32
}
Header is the batch header. A producer leaves PartitionId, BaseOffset, and BaseTimestamp zero; the server stamps them.
func DecodeHeader ¶
DecodeHeader reads a batch header from the front of data.
func (Header) Checksum ¶
Checksum computes the batch checksum: XXH3-64 over the six header meta fields followed by every frame's stored 8-byte checksum field in message order. Message bodies are bound transitively through the frame checksums.
func (Header) EncodeInto ¶
EncodeInto writes the header into the first HeaderSize bytes of b and zeroes the reserved tail.
type MessageHeader ¶
type MessageHeader struct {
Checksum uint64
Id [16]byte
OffsetDelta uint32
TimestampDelta uint32
UserHeadersLength uint32
PayloadLength uint32
}
MessageHeader is a message frame header. OffsetDelta and TimestampDelta resolve against the batch header's stamped bases; Checksum is XXH3-64 over frame[8:48] followed by the payload and the user headers.
func DecodeMessageHeader ¶
func DecodeMessageHeader(data []byte) (MessageHeader, error)
DecodeMessageHeader reads a frame header from the front of data, rejecting nonzero reserved bytes.