View Source KafkaEx.Protocol.KayrockProtocol (kafka_ex v1.0.0-rc.1)

This module handles Kayrock request & response handling & parsing. Once Kafka Ex v1.0 is released, this module will be renamed to KayrockProtocol and will become a separated package.

Summary

Functions

Returns the integer API key for a given API name atom (e.g. :metadata → 3).

Converts an error atom to its integer Kafka error code.

Builds kayrock request based on type, api version and opts

Converts an integer Kafka error code to its atom representation.

Returns the maximum protocol version that Kayrock supports for the given API.

Parses response based on request type and response

Extracts operation name and API version from a Kayrock request struct.

Returns the response deserializer function for a given request struct.

Serializes a Kayrock request struct to wire-format iodata.

Functions

@spec api_key(atom()) :: non_neg_integer()

Returns the integer API key for a given API name atom (e.g. :metadata → 3).

Link to this function

atom_to_error_code!(atom)

View Source
@spec atom_to_error_code!(atom()) :: integer()

Converts an error atom to its integer Kafka error code.

Link to this function

build_request(atom, api_version, opts)

View Source

Builds kayrock request based on type, api version and opts

Link to this function

error_code_to_atom(code)

View Source
@spec error_code_to_atom(integer()) :: atom()

Converts an integer Kafka error code to its atom representation.

Link to this function

max_supported_version(api_name)

View Source
@spec max_supported_version(atom()) :: non_neg_integer()

Returns the maximum protocol version that Kayrock supports for the given API.

Link to this function

parse_response(atom, response)

View Source

Parses response based on request type and response

@spec request_info(struct()) :: {atom(), non_neg_integer()}

Extracts operation name and API version from a Kayrock request struct.

Returns {operation, api_version} tuple where:

  • operation is an atom like :metadata, :produce, :fetch, etc.
  • api_version is an integer like 0, 1, 2, etc.
Link to this function

response_deserializer(request)

View Source
@spec response_deserializer(struct()) :: (binary() -> {struct(), binary()})

Returns the response deserializer function for a given request struct.

Link to this function

serialize_request(request)

View Source
@spec serialize_request(struct()) :: iodata()

Serializes a Kayrock request struct to wire-format iodata.