3 #include <kafka/Project.h>
5 #include <kafka/Header.h>
6 #include <kafka/Types.h>
8 #include <librdkafka/rdkafka.h>
11 namespace KAFKA_API {
namespace clients {
namespace producer {
21 using Id = std::uint64_t;
38 const Topic&
topic()
const {
return _topic; }
48 Key
key()
const {
return _key; }
53 Value
value()
const {
return _value; }
58 Optional<Id>
id()
const {
return _id; }
63 const Headers&
headers()
const {
return _headers; }
91 std::string toString()
const
93 return _topic +
"-" + (_partition == RD_KAFKA_PARTITION_UA ?
"NA" : std::to_string(_partition)) + std::string(
":")
94 + (_id ? (std::to_string(*_id) + std::string(
", ")) :
" ")
95 + (_headers.empty() ?
"" : (
"headers[" + KAFKA_API::toString(_headers) +
"], "))
96 + _key.toString() + std::string(
"/") + _value.toString();
101 Partition _partition;
A key/value pair to be sent to Kafka.
Definition: ProducerRecord.h:19
Key key() const
The key (or null if no key is specified).
Definition: ProducerRecord.h:48
Partition partition() const
The partition to which the record will be sent (or UNKNOWN_PARTITION if no partition was specified).
Definition: ProducerRecord.h:43
void setKey(const Key &key)
Set the key.
Definition: ProducerRecord.h:79
Headers & headers()
The headers.
Definition: ProducerRecord.h:69
const Topic & topic() const
The topic this record is being sent to.
Definition: ProducerRecord.h:38
void setPartition(Partition partition)
Set the partition.
Definition: ProducerRecord.h:74
void setId(Id id)
Set the record id.
Definition: ProducerRecord.h:89
void setValue(const Value &value)
Set the value.
Definition: ProducerRecord.h:84
Optional< Id > id() const
The id to identify the message (consistent with Producer::Metadata::recordId()).
Definition: ProducerRecord.h:58
Value value() const
The value.
Definition: ProducerRecord.h:53
const Headers & headers() const
The headers.
Definition: ProducerRecord.h:63