protocol

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIKeyProduce              int16 = 0
	APIKeyFetch                int16 = 1
	APIKeyListOffsets          int16 = 2
	APIKeyMetadata             int16 = 3
	APIKeyOffsetCommit         int16 = 8
	APIKeyOffsetFetch          int16 = 9
	APIKeyFindCoordinator      int16 = 10
	APIKeyJoinGroup            int16 = 11
	APIKeyHeartbeat            int16 = 12
	APIKeyLeaveGroup           int16 = 13
	APIKeySyncGroup            int16 = 14
	APIKeyDescribeGroups       int16 = 15
	APIKeyListGroups           int16 = 16
	APIKeyApiVersion           int16 = 18
	APIKeyCreateTopics         int16 = 19
	APIKeyDeleteTopics         int16 = 20
	APIKeyOffsetForLeaderEpoch int16 = 23
	APIKeyDescribeConfigs      int16 = 32
	APIKeyAlterConfigs         int16 = 33
	APIKeyCreatePartitions     int16 = 37
	APIKeyDeleteGroups         int16 = 42
)

API keys supported by KafScale.

View Source
const (
	NONE                         int16 = 0
	OFFSET_OUT_OF_RANGE          int16 = 1
	UNKNOWN_TOPIC_OR_PARTITION   int16 = 3
	UNKNOWN_TOPIC_ID             int16 = 100
	UNKNOWN_SERVER_ERROR         int16 = -1
	REQUEST_TIMED_OUT            int16 = 7
	COORDINATOR_LOAD_IN_PROGRESS int16 = 14
	COORDINATOR_NOT_AVAILABLE    int16 = 15
	INVALID_REQUEST              int16 = 42
	ILLEGAL_GENERATION           int16 = 22
	UNKNOWN_MEMBER_ID            int16 = 25
	REBALANCE_IN_PROGRESS        int16 = 27
	GROUP_ID_NOT_FOUND           int16 = 69
	INVALID_TOPIC_EXCEPTION      int16 = 17
	INVALID_CONFIG               int16 = 40
	TOPIC_ALREADY_EXISTS         int16 = 36
	TOPIC_AUTHORIZATION_FAILED   int16 = 29
	GROUP_AUTHORIZATION_FAILED   int16 = 30
	CLUSTER_AUTHORIZATION_FAILED int16 = 31
	INVALID_PARTITIONS           int16 = 37
	UNSUPPORTED_VERSION          int16 = 35
	NOT_LEADER_OR_FOLLOWER       int16 = 6
	NOT_COORDINATOR              int16 = 16
)

Variables

This section is empty.

Functions

func EncodeResponse

func EncodeResponse(correlationID int32, apiVersion int16, resp kmsg.Response) []byte

EncodeResponse serializes a kmsg response with the proper header prepended. The API key and flexibility are derived from the response itself.

ApiVersions (key 18) is a special case per KIP-511: the response body uses flexible encoding starting at version 3, but the response *header* is always the non-flexible v0 header (no tagged-fields byte). Clients rely on this to implement the v0 fallback during version negotiation.

func GroupResponseErrorCode added in v1.6.0

func GroupResponseErrorCode(apiKey int16, apiVersion int16, resp []byte) (int16, bool)

GroupResponseErrorCode extracts the top-level error code from already- serialized group response bytes, accounting for flexible headers and version-dependent layout.

func SkipResponseHeader added in v1.6.0

func SkipResponseHeader(apiKey, apiVersion int16, data []byte) ([]byte, bool)

SkipResponseHeader skips the correlation ID and (for flexible versions) the tagged fields section. Returns the remaining body bytes.

func WriteFrame

func WriteFrame(w io.Writer, payload []byte) error

WriteFrame writes payload prefixed with its length to w.

Types

type Frame

type Frame struct {
	Length  int32
	Payload []byte
}

Frame represents a Kafka request or response frame.

func ReadFrame

func ReadFrame(r io.Reader) (*Frame, error)

ReadFrame reads a single size-prefixed frame from r.

type MetadataBroker

type MetadataBroker = kmsg.MetadataResponseBroker

type MetadataTopic

type MetadataTopic = kmsg.MetadataResponseTopic

type ProduceRequest

type ProduceRequest = kmsg.ProduceRequest

type RequestHeader

type RequestHeader struct {
	APIKey        int16
	APIVersion    int16
	CorrelationID int32
	ClientID      *string
}

RequestHeader carries the parsed Kafka request header fields. kmsg does not handle headers — they must be parsed/written manually.

func ParseRequest

func ParseRequest(b []byte) (*RequestHeader, kmsg.Request, error)

ParseRequest decodes a full request frame (header + body) into the parsed header and a concrete kmsg request type.

func ParseRequestBody added in v1.6.0

func ParseRequestBody(header *RequestHeader, body []byte) (*RequestHeader, kmsg.Request, error)

ParseRequestBody decodes the body bytes into a concrete kmsg request using the API key and version from the already-parsed header. Use this when the header has already been parsed via ParseRequestHeader to avoid re-parsing.

func ParseRequestHeader

func ParseRequestHeader(b []byte) (*RequestHeader, []byte, error)

ParseRequestHeader decodes the header portion from raw frame bytes and returns the header plus the remaining body bytes.

Jump to

Keyboard shortcuts

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