diff --git a/include/cppkafka/consumer.h b/include/cppkafka/consumer.h index 5b7f634..97036ac 100644 --- a/include/cppkafka/consumer.h +++ b/include/cppkafka/consumer.h @@ -79,17 +79,17 @@ class TopicConfiguration; * consumer.subscribe({ "my_topic" }); * while (true) { * // Poll. This will optionally return a message. It's necessary to check if it's a valid - * // one before using it or bad things will happen + * // one before using it * Message msg = consumer.poll(); * if (msg) { - * // It's a valid message! * if (!msg.get_error()) { * // It's an actual message. Get the payload and print it to stdout * cout << msg.get_payload().as_string() << endl; * } - * else { - * // Is it an error notification - * // ... + * else if (!msg.is_eof()) { + * // Is it an error notification, handle it. + * // This is explicitly skipping EOF notifications as they're not actually errors, + * // but that's how rdkafka provides them * } * } * } diff --git a/include/cppkafka/message.h b/include/cppkafka/message.h index a307ea0..dc0ae10 100644 --- a/include/cppkafka/message.h +++ b/include/cppkafka/message.h @@ -48,7 +48,7 @@ class MessageTimestamp; * * This is a non copyable, movable class that wraps a rd_kafka_message_t*. * - * Messages can be empty (contain a null rd_kafka_message_t*). Therefore, users should check + * Messages can be empty (contain a null rd_kafka_message_t*). Therefore, users must check * that the message isn't empty by using the operator bool() before using them. This is especially * necessary when calling Consumer::poll() as any poll operation that returns a null pointer will * return an empty message. @@ -151,6 +151,9 @@ private: Buffer key_; }; +/** + * Represents a message's timestamp + */ class CPPKAFKA_API MessageTimestamp { public: /** diff --git a/include/cppkafka/producer.h b/include/cppkafka/producer.h index 0159816..075a67e 100644 --- a/include/cppkafka/producer.h +++ b/include/cppkafka/producer.h @@ -65,7 +65,7 @@ class TopicConfiguration; * Producer producer(config); * * // Create some key and payload - * string key = "creative_key_name"; + * string key = "some key"; * string payload = "some payload"; * * // Write a message into an unassigned partition @@ -78,6 +78,9 @@ class TopicConfiguration; */ class CPPKAFKA_API Producer : public KafkaHandleBase { public: + /** + * The policy to use for the payload. The default policy is COPY_PAYLOAD + */ enum PayloadPolicy { COPY_PAYLOAD = RD_KAFKA_MSG_F_COPY, ///< Means RD_KAFKA_MSG_F_COPY FREE_PAYLOAD = RD_KAFKA_MSG_F_FREE ///< Means RD_KAFKA_MSG_F_FREE