class OffsetResponse

Header File: <libkafka_asio/offset_response.h>

Namespace: libkafka_asio

Implementation of the Kafka OffsetResponse as described on the Kafka wiki. An object of this type will be given as response object to the handler function when invoking an offset request.

Member Functions

TopicPartitionOffset

Topic::Partition::OptionalType TopicPartitionOffset(const String& topic_name,
                                                    Int32 partition) const

Search for offset data for the given topic partition inside this response object. If no such data can be found, the return value is empty.

// Assume the response is an argument of the request handler function
OffsetResponse::OptionalType response;

// Get the offset data for topic 'foo' partition 1
OffsetResponse::Topic::Partition::OptionalType offsets;
offsets = response->TopicPartitionOffset("foo", 1);
if (offsets)
{
    // [...]
}

topics

const Topics& topics() const

Returns a reference to the set of topics, offsets have been received for.

Types

Topic

struct Topic {
    Partitions partitions;
}
  • partitions: Set of partitions of this topic for which offset data has been received.

Partition

struct Partition {
    Int16               error_code;
    std::vector<Int64>  offsets;
}
  • error_code: Kafka error for this topic partition.
  • offsets: Vector of offsets (std::vector<Int64>) received for this topic partition.
  • partition: Number, identifying this topic partition.

Topics

typedef std::map<String, Topic> Topics

Map that associates the offset response part of topics to their topic names.

Partitions

typedef std::map<Int32, Partition> Partitions

Map that associates a Partition object to the partition id.

OptionalType

typedef boost::optional<OffsetResponse> OptionalType

A offset response object wrapped using Boost optional. Such an object will be used for offset request handler functions.