View Source KafkaEx.Protocol.Kayrock.LeaveGroup.ResponseHelpers (kafka_ex v1.0.0-rc.1)
Shared helper functions for parsing LeaveGroup responses across all versions (V0-V4).
Version differences:
- V0: No throttle_time_ms, no members. Returns
{:ok, :no_error}on success. - V1-V2: Adds throttle_time_ms. Returns
{:ok, %LeaveGroup{throttle_time_ms: ...}}. - V3-V4: Adds
membersarray with per-member error codes (KIP-345 batch leave). Returns{:ok, %LeaveGroup{throttle_time_ms: ..., members: [...]}}. - V4: Flexible version (KIP-482) -- Kayrock handles compact encoding/decoding transparently. Domain-relevant fields are identical to V3.
Summary
Functions
Parses a V0 response (no throttle_time_ms, no members).
Parses a V1/V2 response (includes throttle_time_ms, no members).
Parses a V3+ response (includes throttle_time_ms and members array).
Functions
@spec parse_v0_response(map()) :: {:ok, :no_error} | {:error, KafkaEx.Client.Error.t()}
Parses a V0 response (no throttle_time_ms, no members).
Returns {:ok, :no_error} on success to preserve the existing V0 contract.
@spec parse_v1_v2_response(map()) :: {:ok, KafkaEx.Messages.LeaveGroup.t()} | {:error, KafkaEx.Client.Error.t()}
Parses a V1/V2 response (includes throttle_time_ms, no members).
Returns {:ok, %LeaveGroup{}} on success with throttle_time_ms populated.
@spec parse_v3_plus_response(map()) :: {:ok, KafkaEx.Messages.LeaveGroup.t()} | {:error, KafkaEx.Client.Error.t()}
Parses a V3+ response (includes throttle_time_ms and members array).
Returns {:ok, %LeaveGroup{throttle_time_ms: ..., members: [...]}} on success.
Each member in the members list has:
member_id- the member IDgroup_instance_id- the static membership instance ID (nil for dynamic)error- the error code as an atom (e.g.,:no_error,:unknown_member_id)
The top-level error_code is checked first. If it indicates an error, the
per-member results are not included in the error response.