protocol

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 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

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
	APIKeyInitProducerID       int16 = 22
	APIKeyOffsetForLeaderEpoch int16 = 23
	APIKeyDescribeConfigs      int16 = 32
	APIKeyAlterConfigs         int16 = 33
	APIKeyCreatePartitions     int16 = 37
	APIKeyDeleteGroups         int16 = 42
)

API keys supported by KafScale.

View Source
const (
	OUT_OF_ORDER_SEQUENCE_NUMBER int16 = 45
	INVALID_PRODUCER_EPOCH       int16 = 47
	INVALID_REQUIRED_ACKS        int16 = 21
	NONE                         int16 = 0
	OFFSET_OUT_OF_RANGE          int16 = 1
	CORRUPT_MESSAGE              int16 = 2
	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
	NON_EMPTY_GROUP              int16 = 68
	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
	LEADER_NOT_AVAILABLE         int16 = 5
	NOT_LEADER_OR_FOLLOWER       int16 = 6
	NOT_COORDINATOR              int16 = 16
	KAFKA_STORAGE_ERROR          int16 = 56
)
View Source
const ApiVersionsMaxVersion int16 = 4

ApiVersionsMaxVersion is the highest ApiVersions schema supported by KafScale.

View Source
const DefaultResponseWriteLimit = 5 * time.Minute

DefaultResponseWriteLimit bounds the whole frame, including trickle readers.

View Source
const DefaultResponseWriteTimeout = 30 * time.Second

DefaultResponseWriteTimeout bounds a client that stops reading responses.

View Source
const ResponseWriteChunk = 256 << 10

Variables

This section is empty.

Functions

func ClientGone

func ClientGone(ctx context.Context) <-chan struct{}

ClientGone returns the connection-close signal, or nil without a connection.

func ContextUntilClientGone

func ContextUntilClientGone(ctx context.Context) (context.Context, context.CancelFunc)

ContextUntilClientGone is for waits that have no work to preserve after EOF. Produce must retain the original handler context to finish already-read data.

func ContextWithClientGone

func ContextWithClientGone(ctx context.Context, gone <-chan struct{}) context.Context

ContextWithClientGone reports a closed client separately from request cancellation: already-read requests may still need to finish after EOF.

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

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 ProduceErrorResponse added in v2.1.0

func ProduceErrorResponse(req *kmsg.ProduceRequest, code int16) *kmsg.ProduceResponse

func SkipResponseHeader

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 UnsupportedTransactionResponse added in v2.1.0

func UnsupportedTransactionResponse(req kmsg.Request) kmsg.Response

UnsupportedTransactionResponse returns a schema-correct failure for features outside nontransactional idempotence. Both proxy and broker use this boundary. Per-resource APIs must echo every requested resource with an error; an empty response or a zero-initialized response can be interpreted as success.

func WriteFrame

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

WriteFrame writes payload prefixed with its length to w.

func WriteFrameWithDeadline

func WriteFrameWithDeadline(conn net.Conn, payload []byte, timeout time.Duration) error

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

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