View Source KafkaEx.Messages.RecordMetadata (kafka_ex v1.0.0-rc.1)

Metadata about a record that has been acknowledged by the server.

This struct represents the response from a produce operation, containing information about where the record was stored in Kafka.

Java equivalent: org.apache.kafka.clients.producer.RecordMetadata

Fields

  • :topic - The topic the messages were produced to
  • :partition - The partition the messages were produced to
  • :base_offset - The offset assigned to the first message in the batch
  • :log_append_time - The timestamp assigned by the broker (v2+, -1 if not available)
  • :log_start_offset - The start offset of the log (v5+)
  • :throttle_time_ms - Time in ms the request was throttled (v3+)

Summary

Functions

Builds a RecordMetadata struct from response data.

Returns the offset of the record in the topic/partition.

Returns the timestamp of the record.

Types

@type t() :: %KafkaEx.Messages.RecordMetadata{
  base_offset: non_neg_integer(),
  log_append_time: integer() | nil,
  log_start_offset: non_neg_integer() | nil,
  partition: non_neg_integer(),
  throttle_time_ms: non_neg_integer() | nil,
  topic: String.t()
}

Functions

@spec build(Keyword.t()) :: t()

Builds a RecordMetadata struct from response data.

Options

  • :topic - (required) The topic name
  • :partition - (required) The partition number
  • :base_offset - (required) The base offset assigned to the batch
  • :log_append_time - The broker-assigned timestamp (-1 if not using LogAppendTime)
  • :log_start_offset - The log start offset (v5+)
  • :throttle_time_ms - Request throttle time in milliseconds (v3+)
@spec offset(t()) :: non_neg_integer()

Returns the offset of the record in the topic/partition.

This is an alias for base_offset to match Java API.

Link to this function

timestamp(record_metadata)

View Source
@spec timestamp(t()) :: integer() | nil

Returns the timestamp of the record.

For records using CreateTime, this is the timestamp provided by the producer. For records using LogAppendTime, this is the broker-assigned timestamp. Returns nil if timestamp is not available or -1.