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

Shared helper functions for parsing protocol responses.

This module provides common functionality for handling responses across multiple protocol implementations (OffsetCommit, OffsetFetch, etc.).

Summary

Functions

Builds a response tuple from either a list of offsets or an error.

Iterates over partitions data with fail-fast behavior.

Iterates over topics data with fail-fast behavior.

Parses time values for list_offsets requests.

Types

@type error_tuple() :: {atom(), String.t(), non_neg_integer()}
@type parser_fn() :: (String.t(), list() -> {:ok, any()} | {:error, error_tuple()})

Functions

@spec build_response(list() | error_tuple()) ::
  {:ok, list()} | {:error, KafkaEx.Client.Error.t()}

Builds a response tuple from either a list of offsets or an error.

Link to this function

fail_fast_iterate_partitions(partitions_data, topic, parser_fn)

View Source
@spec fail_fast_iterate_partitions(list(), String.t(), parser_fn()) ::
  {:ok, list()} | {:error, error_tuple()}

Iterates over partitions data with fail-fast behavior.

Link to this function

fail_fast_iterate_topics(topics_data, parser_fn, opts \\ [])

View Source
@spec fail_fast_iterate_topics(list(), parser_fn(), Keyword.t()) ::
  list() | error_tuple()

Iterates over topics data with fail-fast behavior.

Uses name and partitions keys by default (for OffsetCommit/OffsetFetch). Pass custom keys for APIs with different field names (e.g., ListOffsets uses topic/partition_responses).

@spec parse_time(:latest | :earliest | integer() | DateTime.t()) :: integer()

Parses time values for list_offsets requests.