class OffsetRequest

Header File: <libkafka_asio/offset_request.h>

Namespace: libkafka_asio

Implementation of the Kafka OffsetRequest as described on the Kafka wiki. Offset requests are used to get the valid range of offsets for a topic partition from a Kafka server. They must be send to the Kafka broker, which is currently acting as leader for that topic partition.

Member Functions

FetchTopicOffset

void FetchTopicOffset(const String& topic_name,
                      Int32 partition,
                      Int64 time,
                      Int32 max_number_of_offsets)

Fetches offset information for the given topic partition. The optional time parameter can be used to ask for messages before a certain time in the past. Time must be specified in milliseconds. Two special values exist for this parameters:

  • libkafka_asio::constants::kOffsetTimeLatest (-1) (Default) and
  • libkafka_asio::constants::kOffsetTimeEarliest (-2).

The maximum number of offsets to fetch can optionally be specified as well.

OffsetRequest request;

// Fetch latest offset for topic 'foo' partition 0
request.FetchOffset("foo", 0);

Clear

void Clear()

Clears all entries of this request for fetching offsets of topic partitions.

replica_id

Int32 replica_id() const

Always returns -1.

topics

const TopicVector& topics() const

Returns a reference to the list of topics of this offset request. This method is mainly used internally for getting the request data during the conversion to the Kafka wire format.

Types

Topic

struct Topic
  • topic_name: Name of the topic to fetch data for.
  • partitions: Set of partitions of this topic to fetch offset data for.

Topic::Partition

struct Topic::Partition
  • partition: Number, identifying this topic partition.
  • time: Time in milliseconds to ask for messages before.
  • max_number_of_offsets: The maximum number of offsets to fetch for this topic partition.

ResponseType

typedef OffsetResponse ResponseType

Type of the response object of an offset request.

MutableResponseType

typedef MutableOffsetResponse MutableResponseType

Type of a mutable response object for a offset request. This type is used by the library at when reading-in the response from a Kafka server.

TopicVector

typedef std::vector<Topic> TopicVector

Vector of topics to fetch offset data for.