Skip to content

Commit

Permalink
Merge pull request #5 from dantswain/docs_n_specs
Browse files Browse the repository at this point in the history
Docs n specs
  • Loading branch information
dantswain committed Dec 15, 2019
2 parents a5f1cda + 655ab0e commit 2eaea75
Show file tree
Hide file tree
Showing 44 changed files with 7,000 additions and 805 deletions.
103 changes: 89 additions & 14 deletions lib/generated/add_offsets_to_txn.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
defmodule(Kayrock.AddOffsetsToTxn) do
@moduledoc false
@api :add_offsets_to_txn
@moduledoc "Kayrock-generated module for the Kafka `#{@api}` API\n"
_ = " THIS CODE IS GENERATED BY KAYROCK"

(
@vmin 0
@vmax 0
)

defmodule(V0.Request) do
@moduledoc false
@vsn 0
@api :add_offsets_to_txn
@schema transactional_id: :string,
producer_id: :int64,
producer_epoch: :int16,
group_id: :string
@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(
Expand All @@ -16,23 +30,41 @@ defmodule(Kayrock.AddOffsetsToTxn) do
)

import(Elixir.Kayrock.Serialize)
@type t :: %__MODULE__{}
@typedoc "Request struct for the Kafka `#{@api}` API v#{@vsn}\n"
@type t :: %__MODULE__{
transactional_id: nil | binary(),
producer_id: nil | integer(),
producer_epoch: nil | integer(),
group_id: nil | binary(),
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(:add_offsets_to_txn)
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
[transactional_id: :string, producer_id: :int64, producer_epoch: :int16, group_id: :string]
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,
Expand Down Expand Up @@ -66,29 +98,51 @@ defmodule(Kayrock.AddOffsetsToTxn) do
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
@moduledoc false
@vsn 0
@api :add_offsets_to_txn
@schema throttle_time_ms: :int32, error_code: :int16
@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, error_code: nil, correlation_id: nil)
@type t :: %__MODULE__{}
@typedoc "Response struct for the Kafka `#{@api}` API v#{@vsn}\n"
@type t :: %__MODULE__{
throttle_time_ms: nil | integer(),
error_code: 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(:add_offsets_to_txn)
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, error_code: :int16]
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

Expand All @@ -115,17 +169,38 @@ defmodule(Kayrock.AddOffsetsToTxn) do
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

@type request_t :: Kayrock.AddOffsetsToTxn.V0.Request.t()
@type response_t :: Kayrock.AddOffsetsToTxn.V0.Response.t()
def(min_vsn) do
0
end
(
@typedoc "Union type for all request structs for this API"
@type request_t :: Kayrock.AddOffsetsToTxn.V0.Request.t()
)

def(max_vsn) do
0
end
(
@typedoc "Union type for all response structs for this API"
@type response_t :: Kayrock.AddOffsetsToTxn.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
114 changes: 100 additions & 14 deletions lib/generated/add_partitions_to_txn.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
defmodule(Kayrock.AddPartitionsToTxn) do
@moduledoc false
@api :add_partitions_to_txn
@moduledoc "Kayrock-generated module for the Kafka `#{@api}` API\n"
_ = " THIS CODE IS GENERATED BY KAYROCK"

(
@vmin 0
@vmax 0
)

defmodule(V0.Request) do
@moduledoc false
@vsn 0
@api :add_partitions_to_txn
@schema transactional_id: :string,
producer_id: :int64,
producer_epoch: :int16,
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(
Expand All @@ -16,19 +30,35 @@ defmodule(Kayrock.AddPartitionsToTxn) do
)

import(Elixir.Kayrock.Serialize)
@type t :: %__MODULE__{}
@typedoc "Request struct for the Kafka `#{@api}` API v#{@vsn}\n"
@type t :: %__MODULE__{
transactional_id: nil | binary(),
producer_id: nil | integer(),
producer_epoch: nil | integer(),
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(:add_partitions_to_txn)
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
[
transactional_id: :string,
Expand All @@ -38,6 +68,8 @@ defmodule(Kayrock.AddPartitionsToTxn) do
]
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,
Expand Down Expand Up @@ -88,25 +120,56 @@ defmodule(Kayrock.AddPartitionsToTxn) do
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
@moduledoc false
@vsn 0
@api :add_partitions_to_txn
@schema throttle_time_ms: :int32,
errors:
{:array,
[
topic: :string,
partition_errors: {:array, [partition: :int32, error_code: :int16]}
]}
@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, errors: [], correlation_id: nil)
@type t :: %__MODULE__{}
@typedoc "Response struct for the Kafka `#{@api}` API v#{@vsn}\n"
@type t :: %__MODULE__{
throttle_time_ms: nil | integer(),
errors: [
%{
topic: nil | binary(),
partition_errors: [%{partition: nil | integer(), error_code: 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(:add_partitions_to_txn)
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,
Expand All @@ -116,6 +179,8 @@ defmodule(Kayrock.AddPartitionsToTxn) do
]
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

Expand Down Expand Up @@ -184,17 +249,38 @@ defmodule(Kayrock.AddPartitionsToTxn) do
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

@type request_t :: Kayrock.AddPartitionsToTxn.V0.Request.t()
@type response_t :: Kayrock.AddPartitionsToTxn.V0.Response.t()
def(min_vsn) do
0
end
(
@typedoc "Union type for all request structs for this API"
@type request_t :: Kayrock.AddPartitionsToTxn.V0.Request.t()
)

def(max_vsn) do
0
end
(
@typedoc "Union type for all response structs for this API"
@type response_t :: Kayrock.AddPartitionsToTxn.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

0 comments on commit 2eaea75

Please sign in to comment.