batch

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const HeaderSize = 256

HeaderSize is the size of the batch header. Bytes past the declared fields are reserved and stay zero.

View Source
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 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

func DecodeHeader(data []byte) (Header, error)

DecodeHeader reads a batch header from the front of data.

func (Header) Checksum

func (h Header) Checksum(frameChecksums []byte) uint64

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

func (h Header) EncodeInto(b []byte)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL