brodex v0.0.2 Brodex.MessageSet View Source

Represents a Kafka message set.

Wrapper of :brod.message_set.

Link to this section Summary

Link to this section Types

Link to this type

record()

View Source
record() ::
  {:kafka_message_set, topic :: Brodex.topic(), partition :: Brodex.partition(),
   high_wm_offset :: integer(),
   messages :: [Brodex.record()] | {:incomplete_batch, Brodex.int32()}}

:brod.message_set

Link to this type

t()

View Source
t() :: %Brodex.MessageSet{
  high_wm_offset: integer(),
  messages: [Brodex.Message.t()] | {:incomplete_batch, Brodex.int32()},
  partition: Brodex.partition(),
  topic: Brodex.topic()
}

Link to this section Functions

Link to this function

from_record(kafka_message_set_record)

View Source
from_record(record()) :: t()

Converts a record/0 into a Brodex.MessageSet.

Examples

iex>  Brodex.MessageSet.from_record(
...>    {:kafka_message_set, "my_topic", 0, 33,
...>    [
...>      {:kafka_message, 31, "", "a", :create, 1_564_023_091_657, []},
...>      {:kafka_message, 32, "", "b", :create, 1_564_023_091_894, []}
...>    ]}
...>  )
%Brodex.MessageSet{
  high_wm_offset: 33,
  messages: [
    %Brodex.Message{
      headers: [],
      key: "",
      offset: 31,
      ts: 1_564_023_091_657,
      ts_type: :create,
      value: "a"
    },
    %Brodex.Message{
      headers: [],
      key: "",
      offset: 32,
      ts: 1_564_023_091_894,
      ts_type: :create,
      value: "b"
    }
  ],
  partition: 0,
  topic: "my_topic"
}

Converts a Brodex.MessageSet into record/0.

Examples

iex> Brodex.MessageSet.to_record(%Brodex.MessageSet{
...>   topic: "hello",
...>   partition: 0,
...>   high_wm_offset: 1,
...>   messages: [
...>     %Brodex.Message{
...>       offset: 1,
...>       key: "",
...>       value: "world",
...>       ts_type: :undefined,
...>       ts: :undefined,
...>       headers: []
...>     }
...>   ]
...> })
{:kafka_message_set, "hello", 0, 1,
 [{:kafka_message, 1, "", "world", :undefined, :undefined, []}]}