brodex v0.0.2 Brodex.Message View Source

Represents a Kafka message.

Wrapper of :brod.message.

Link to this section Summary

Link to this section Types

Link to this type

record()

View Source
record() ::
  {:kafka_message, offset :: Brodex.offest(), key :: Brodex.key(),
   value :: Brodex.value(), ts_type :: timestamp_type(),
   ts :: :undefined | Brodex.int64(), headers :: Brodex.headers()}

:brod.message

Link to this type

t()

View Source
t() :: %Brodex.Message{
  headers: Brodex.headers(),
  key: Brodex.key(),
  offset: Brodex.offest(),
  ts: :undefined | Brodex.int64(),
  ts_type: timestamp_type(),
  value: Brodex.value()
}
Link to this type

timestamp_type()

View Source
timestamp_type() :: :undefined | :create | :append

:kpro.timestamp_type

Link to this section Functions

Link to this function

from_record(kafka_message_record)

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

Converts a record/0 into a Brodex.Message.

Examples

iex> Brodex.Message.from_record({:kafka_message, 164, "", "hello", :create, 1_563_946_803_056, []})
%Brodex.Message{
  headers: [],
  key: "",
  offset: 164,
  ts: 1_563_946_803_056,
  ts_type: :create,
  value: "hello"
}

iex> Brodex.Message.from_record({:kafka_message, 164, "", "hello", :undefined, :undefined, []})
%Brodex.Message{
  headers: [],
  key: "",
  offset: 164,
  ts: :undefined,
  ts_type: :undefined,
  value: "hello"
}

Converts a Brodex.Message into a record/0.

Examples

iex> Brodex.Message.to_record(%Brodex.Message{
...>   headers: [],
...>   key: "",
...>   offset: 164,
...>   ts: 1_563_946_803_056,
...>   ts_type: :create,
...>   value: "hello"
...> })
{:kafka_message, 164, "", "hello", :create, 1_563_946_803_056, []}