View Source KafkaEx.Protocol.Kayrock.ApiVersions.ResponseHelpers (kafka_ex v1.0.0-rc.1)

Shared helper functions for parsing ApiVersions responses across protocol versions.

All ApiVersions response versions share the same core parsing logic:

  • Convert api_keys list to a map keyed by api_key
  • Extract throttle_time_ms (V1+; nil for V0)
  • Map error codes to tagged error tuples

This module extracts that logic so individual version implementations can delegate here instead of duplicating code.

Summary

Functions

Converts a list of api_key entries into a map keyed by api_key.

Parses an ApiVersions response that includes throttle_time_ms (V1+).

Parses an ApiVersions V0 response (no throttle_time_ms field).

Functions

Link to this function

build_api_versions_map(versions)

View Source
@spec build_api_versions_map([map()]) :: %{
  required(non_neg_integer()) => KafkaEx.Messages.ApiVersions.api_version()
}

Converts a list of api_key entries into a map keyed by api_key.

@spec parse(map()) ::
  {:ok, KafkaEx.Messages.ApiVersions.t()} | {:error, KafkaEx.Client.Error.t()}

Parses an ApiVersions response that includes throttle_time_ms (V1+).

Returns

  • {:ok, %ApiVersions{}} on success (error_code == 0)
  • {:error, %Error{}} on Kafka error
@spec parse_v0(map()) ::
  {:ok, KafkaEx.Messages.ApiVersions.t()} | {:error, KafkaEx.Client.Error.t()}

Parses an ApiVersions V0 response (no throttle_time_ms field).

Returns

  • {:ok, %ApiVersions{}} on success (error_code == 0)
  • {:error, %Error{}} on Kafka error