librdkafka
The Apache Kafka C/C++ client library
RdKafka::Headers Class Referenceabstract

Headers object. More...

#include <rdkafkacpp.h>

Data Structures

class  Header
 Header object. More...
 

Public Member Functions

virtual ErrorCode add (const std::string &key, const void *value, size_t value_size)=0
 Adds a Header to the end of the list. More...
 
virtual ErrorCode add (const std::string &key, const std::string &value)=0
 Adds a Header to the end of the list. More...
 
virtual ErrorCode add (const Header &header)=0
 Adds a Header to the end of the list. More...
 
virtual ErrorCode remove (const std::string &key)=0
 Removes all the Headers of a given key. More...
 
virtual std::vector< Headerget (const std::string &key) const =0
 Gets all of the Headers of a given key. More...
 
virtual Header get_last (const std::string &key) const =0
 Gets the last occurrence of a Header of a given key. More...
 
virtual std::vector< Headerget_all () const =0
 Returns all Headers. More...
 
virtual size_t size () const =0
 

Static Public Member Functions

static Headerscreate ()
 Create a new instance of the Headers object. More...
 
static Headerscreate (const std::vector< Header > &headers)
 Create a new instance of the Headers object from a std::vector. More...
 

Detailed Description

Headers object.

Represents message headers.

https://cwiki.apache.org/confluence/display/KAFKA/KIP-82+-+Add+Record+Headers

Remarks
Requires Apache Kafka >= 0.11.0 brokers

Member Function Documentation

◆ create() [1/2]

static Headers* RdKafka::Headers::create ( )
static

Create a new instance of the Headers object.

Returns
an empty Headers list

◆ create() [2/2]

static Headers* RdKafka::Headers::create ( const std::vector< Header > &  headers)
static

Create a new instance of the Headers object from a std::vector.

Parameters
headersstd::vector of RdKafka::Headers::Header objects. The headers are copied, not referenced.
Returns
a Headers list from std::vector set to the size of the std::vector

◆ add() [1/3]

virtual ErrorCode RdKafka::Headers::add ( const std::string &  key,
const void *  value,
size_t  value_size 
)
pure virtual

Adds a Header to the end of the list.

Parameters
keyheader key/name
valuebinary value, or NULL
value_sizesize of the value
Returns
an ErrorCode signalling success or failure to add the header.

◆ add() [2/3]

virtual ErrorCode RdKafka::Headers::add ( const std::string &  key,
const std::string &  value 
)
pure virtual

Adds a Header to the end of the list.

Convenience method for adding a std::string as a value for the header.

Parameters
keyheader key/name
valuevalue string
Returns
an ErrorCode signalling success or failure to add the header.

◆ add() [3/3]

virtual ErrorCode RdKafka::Headers::add ( const Header header)
pure virtual

Adds a Header to the end of the list.

This method makes a copy of the passed header.

Parameters
headerExisting header to copy
Returns
an ErrorCode signalling success or failure to add the header.

◆ remove()

virtual ErrorCode RdKafka::Headers::remove ( const std::string &  key)
pure virtual

Removes all the Headers of a given key.

Parameters
keyheader key/name to remove
Returns
An ErrorCode signalling a success or failure to remove the Header.

◆ get()

virtual std::vector<Header> RdKafka::Headers::get ( const std::string &  key) const
pure virtual

Gets all of the Headers of a given key.

Parameters
keyheader key/name
Remarks
If duplicate keys exist this will return them all as a std::vector
Returns
a std::vector containing all the Headers of the given key.

◆ get_last()

virtual Header RdKafka::Headers::get_last ( const std::string &  key) const
pure virtual

Gets the last occurrence of a Header of a given key.

Parameters
keyheader key/name
Remarks
This will only return the most recently added header
Returns
the Header if found, otherwise a Header with an err set to ERR__NOENT.

◆ get_all()

virtual std::vector<Header> RdKafka::Headers::get_all ( ) const
pure virtual

Returns all Headers.

Returns
a std::vector containing all of the Headers

◆ size()

virtual size_t RdKafka::Headers::size ( ) const
pure virtual
Returns
the number of headers.

The documentation for this class was generated from the following file: