Documentation
¶
Index ¶
- Constants
- func ClientGone(ctx context.Context) <-chan struct{}
- func ContextUntilClientGone(ctx context.Context) (context.Context, context.CancelFunc)
- func ContextWithClientGone(ctx context.Context, gone <-chan struct{}) context.Context
- func EncodeResponse(correlationID int32, apiVersion int16, resp kmsg.Response) []byte
- func GroupResponseErrorCode(apiKey int16, apiVersion int16, resp []byte) (int16, bool)
- func ProduceErrorResponse(req *kmsg.ProduceRequest, code int16) *kmsg.ProduceResponse
- func SkipResponseHeader(apiKey, apiVersion int16, data []byte) ([]byte, bool)
- func UnsupportedTransactionResponse(req kmsg.Request) kmsg.Response
- func WriteFrame(w io.Writer, payload []byte) error
- func WriteFrameWithDeadline(conn net.Conn, payload []byte, timeout time.Duration) error
- type Frame
- type MetadataBroker
- type MetadataPartition
- type MetadataTopic
- type ProduceRequest
- type RequestHeader
Constants ¶
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.
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 )
const ApiVersionsMaxVersion int16 = 4
ApiVersionsMaxVersion is the highest ApiVersions schema supported by KafScale.
const DefaultResponseWriteLimit = 5 * time.Minute
DefaultResponseWriteLimit bounds the whole frame, including trickle readers.
const DefaultResponseWriteTimeout = 30 * time.Second
DefaultResponseWriteTimeout bounds a client that stops reading responses.
const ResponseWriteChunk = 256 << 10
Variables ¶
This section is empty.
Functions ¶
func ClientGone ¶
ClientGone returns the connection-close signal, or nil without a connection.
func ContextUntilClientGone ¶
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 ¶
ContextWithClientGone reports a closed client separately from request cancellation: already-read requests may still need to finish after EOF.
func EncodeResponse ¶
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 ¶
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 ¶
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
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 ¶
WriteFrame writes payload prefixed with its length to w.
Types ¶
type MetadataBroker ¶
type MetadataBroker = kmsg.MetadataResponseBroker
type MetadataPartition ¶
type MetadataPartition = kmsg.MetadataResponseTopicPartition
type MetadataTopic ¶
type MetadataTopic = kmsg.MetadataResponseTopic
type ProduceRequest ¶
type ProduceRequest = kmsg.ProduceRequest
type RequestHeader ¶
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.