Add MessageBuilder and use it on producer classes

This commit is contained in:
Matias Fontanini
2017-04-15 16:46:37 -07:00
parent c8154ac6cb
commit e26d7e7db2
10 changed files with 224 additions and 127 deletions

View File

@@ -37,6 +37,7 @@
#include "topic.h"
#include "partition.h"
#include "macros.h"
#include "message_builder.h"
namespace cppkafka {
@@ -72,10 +73,10 @@ class TopicConfiguration;
* string payload = "some payload";
*
* // Write a message into an unassigned partition
* producer.produce(topic, Partition(), payload);
* producer.produce(MessageBuilder(topic).payload(payload));
*
* // Write using a key on a fixed partition (42)
* producer.produce(topic, 42, key, payload);
* producer.produce(MessageBuilder(topic).partition(42).key(key).payload(payload));
*
* \endcode
*/
@@ -112,30 +113,7 @@ public:
* \param partition The partition to write the message to
* \param payload The message payload
*/
void produce(const Topic& topic, const Partition& partition, const Buffer& payload);
/**
* Produces a message
*
* \param topic The topic to write the message to
* \param partition The partition to write the message to
* \param key The message key
* \param payload The message payload
*/
void produce(const Topic& topic, const Partition& partition, const Buffer& key,
const Buffer& payload);
/**
* Produces a message
*
* \param topic The topic to write the message to
* \param partition The partition to write the message to
* \param key The message key
* \param payload The message payload
* \param user_data The opaque data pointer to be used (accesible via Message::private_data)
*/
void produce(const Topic& topic, const Partition& partition, const Buffer& key,
const Buffer& payload, void* user_data);
void produce(const MessageBuilder& builder);
/**
* \brief Polls on this handle