defmodule(Kayrock.DescribeLogDirs) do
@api :describe_log_dirs
@moduledoc "Kayrock-generated module for the Kafka `#{@api}` API\n"
_ = " THIS CODE IS GENERATED BY KAYROCK"
(
@vmin 0
@vmax 0
)
defmodule(V0.Request) do
@vsn 0
@api :describe_log_dirs
@schema topics: {:array, [topic: :string, partitions: {:array, :int32}]}
@moduledoc "Kayrock-generated request struct for Kafka `#{@api}` v#{@vsn} API\nmessages\n\nThe schema of this API is\n```\n#{
inspect(@schema, pretty: true)
}\n```\n"
_ = " THIS CODE IS GENERATED BY KAYROCK"
defstruct(topics: [], correlation_id: nil, client_id: nil)
import(Elixir.Kayrock.Serialize)
@typedoc "Request struct for the Kafka `#{@api}` API v#{@vsn}\n"
@type t :: %__MODULE__{
topics: [%{topic: nil | binary(), partitions: [nil | integer()]}],
correlation_id: nil | integer(),
client_id: nil | binary()
}
@doc "Returns the Kafka API key for this API"
@spec api_key :: integer
def(api_key) do
Kayrock.KafkaSchemaMetadata.api_key(:describe_log_dirs)
end
@doc "Returns the API version (#{@vsn}) implemented by this module"
@spec api_vsn :: integer
def(api_vsn) do
0
end
@doc "Returns a function that can be used to deserialize the wire response from the\nbroker for this message type\n"
@spec response_deserializer :: (binary -> {V0.Response.t(), binary})
def(response_deserializer) do
&V0.Response.deserialize/1
end
@doc "Returns the schema of this message\n\nSee [above](#).\n"
@spec schema :: term
def(schema) do
[topics: {:array, [topic: :string, partitions: {:array, :int32}]}]
end
@doc "Serialize a message to binary data for transfer to a Kafka broker"
@spec serialize(t()) :: iodata
def(serialize(%V0.Request{} = struct)) do
[
<<api_key()::16, api_vsn()::16, struct.correlation_id::32,
byte_size(struct.client_id)::16, struct.client_id::binary>>,
[
case(Map.fetch!(struct, :topics)) do
nil ->
<<-1::32-signed>>
[] ->
<<0::32-signed>>
vals when is_list(vals) ->
[
<<length(vals)::32-signed>>,
for(v <- vals) do
[
serialize(:string, Map.fetch!(v, :topic)),
serialize_array(:int32, Map.fetch!(v, :partitions))
]
end
]
end
]
]
end
end
defimpl(Elixir.Kayrock.Request, for: V0.Request) do
def(serialize(%V0.Request{} = struct)) do
try do
V0.Request.serialize(struct)
rescue
e ->
reraise(Kayrock.InvalidRequestError, {e, struct}, __STACKTRACE__)
end
end
def(api_vsn(%V0.Request{})) do
V0.Request.api_vsn()
end
def(response_deserializer(%V0.Request{})) do
V0.Request.response_deserializer()
end
end
(
@doc "Returns a request struct for this API with the given version"
@spec get_request_struct(integer) :: request_t
)
def(get_request_struct(0)) do
%V0.Request{}
end
defmodule(V0.Response) do
@vsn 0
@api :describe_log_dirs
@schema throttle_time_ms: :int32,
log_dirs:
{:array,
[
error_code: :int16,
log_dir: :string,
topics:
{:array,
[
topic: :string,
partitions:
{:array,
[
partition: :int32,
size: :int64,
offset_lag: :int64,
is_future: :boolean
]}
]}
]}
@moduledoc "Kayrock-generated response struct for Kafka `#{@api}` v#{@vsn} API\nmessages\n\nThe schema of this API is\n```\n#{
inspect(@schema, pretty: true)
}\n```\n"
_ = " THIS CODE IS GENERATED BY KAYROCK"
defstruct(throttle_time_ms: nil, log_dirs: [], correlation_id: nil)
@typedoc "Response struct for the Kafka `#{@api}` API v#{@vsn}\n"
@type t :: %__MODULE__{
throttle_time_ms: nil | integer(),
log_dirs: [
%{
error_code: nil | integer(),
log_dir: nil | binary(),
topics: [
%{
topic: nil | binary(),
partitions: [
%{
partition: nil | integer(),
size: nil | integer(),
offset_lag: nil | integer(),
is_future: nil | integer()
}
]
}
]
}
],
correlation_id: integer()
}
import(Elixir.Kayrock.Deserialize)
@doc "Returns the Kafka API key for this API"
@spec api_key :: integer
def(api_key) do
Kayrock.KafkaSchemaMetadata.api_key(:describe_log_dirs)
end
@doc "Returns the API version (#{@vsn}) implemented by this module"
@spec api_vsn :: integer
def(api_vsn) do
0
end
@doc "Returns the schema of this message\n\nSee [above](#).\n"
@spec schema :: term
def(schema) do
[
throttle_time_ms: :int32,
log_dirs:
{:array,
[
error_code: :int16,
log_dir: :string,
topics:
{:array,
[
topic: :string,
partitions:
{:array,
[partition: :int32, size: :int64, offset_lag: :int64, is_future: :boolean]}
]}
]}
]
end
@doc "Deserialize data for this version of this API\n"
@spec deserialize(binary) :: {t(), binary}
def(deserialize(data)) do
<<correlation_id::32-signed, rest::binary>> = data
deserialize_field(
:root,
:throttle_time_ms,
%__MODULE__{correlation_id: correlation_id},
rest
)
end
defp(deserialize_field(:root, :throttle_time_ms, acc, data)) do
{val, rest} = deserialize(:int32, data)
deserialize_field(:root, :log_dirs, Map.put(acc, :throttle_time_ms, val), rest)
end
defp(deserialize_field(:log_dirs, :error_code, acc, data)) do
{val, rest} = deserialize(:int16, data)
deserialize_field(:log_dirs, :log_dir, Map.put(acc, :error_code, val), rest)
end
defp(deserialize_field(:log_dirs, :log_dir, acc, data)) do
{val, rest} = deserialize(:string, data)
deserialize_field(:log_dirs, :topics, Map.put(acc, :log_dir, val), rest)
end
defp(deserialize_field(:topics, :topic, acc, data)) do
{val, rest} = deserialize(:string, data)
deserialize_field(:topics, :partitions, Map.put(acc, :topic, val), rest)
end
defp(deserialize_field(:partitions, :partition, acc, data)) do
{val, rest} = deserialize(:int32, data)
deserialize_field(:partitions, :size, Map.put(acc, :partition, val), rest)
end
defp(deserialize_field(:partitions, :size, acc, data)) do
{val, rest} = deserialize(:int64, data)
deserialize_field(:partitions, :offset_lag, Map.put(acc, :size, val), rest)
end
defp(deserialize_field(:partitions, :offset_lag, acc, data)) do
{val, rest} = deserialize(:int64, data)
deserialize_field(:partitions, :is_future, Map.put(acc, :offset_lag, val), rest)
end
defp(deserialize_field(:partitions, :is_future, acc, data)) do
{val, rest} = deserialize(:boolean, data)
deserialize_field(:partitions, nil, Map.put(acc, :is_future, val), rest)
end
defp(deserialize_field(:topics, :partitions, acc, data)) do
<<num_elements::32-signed, rest::binary>> = data
{vals, rest} =
if(num_elements > 0) do
Enum.reduce(1..num_elements, {[], rest}, fn _ix, {acc, d} ->
{val, r} = deserialize_field(:partitions, :partition, %{}, d)
{[val | acc], r}
end)
else
{[], rest}
end
deserialize_field(:topics, nil, Map.put(acc, :partitions, Enum.reverse(vals)), rest)
end
defp(deserialize_field(:log_dirs, :topics, acc, data)) do
<<num_elements::32-signed, rest::binary>> = data
{vals, rest} =
if(num_elements > 0) do
Enum.reduce(1..num_elements, {[], rest}, fn _ix, {acc, d} ->
{val, r} = deserialize_field(:topics, :topic, %{}, d)
{[val | acc], r}
end)
else
{[], rest}
end
deserialize_field(:log_dirs, nil, Map.put(acc, :topics, Enum.reverse(vals)), rest)
end
defp(deserialize_field(:root, :log_dirs, acc, data)) do
<<num_elements::32-signed, rest::binary>> = data
{vals, rest} =
if(num_elements > 0) do
Enum.reduce(1..num_elements, {[], rest}, fn _ix, {acc, d} ->
{val, r} = deserialize_field(:log_dirs, :error_code, %{}, d)
{[val | acc], r}
end)
else
{[], rest}
end
deserialize_field(:root, nil, Map.put(acc, :log_dirs, Enum.reverse(vals)), rest)
end
defp(deserialize_field(_, nil, acc, rest)) do
{acc, rest}
end
end
(
@doc "Deserializes raw wire data for this API with the given version"
@spec deserialize(integer, binary) :: {response_t, binary}
)
def(deserialize(0, data)) do
V0.Response.deserialize(data)
end
(
@typedoc "Union type for all request structs for this API"
@type request_t :: Kayrock.DescribeLogDirs.V0.Request.t()
)
(
@typedoc "Union type for all response structs for this API"
@type response_t :: Kayrock.DescribeLogDirs.V0.Response.t()
)
(
@doc "Returns the minimum version of this API supported by Kayrock (#{@vmin})"
@spec min_vsn :: integer
def(min_vsn) do
0
end
)
(
@doc "Returns the maximum version of this API supported by Kayrock (#{@vmax})"
@spec max_vsn :: integer
def(max_vsn) do
0
end
)
end