Skip to content

Instantly share code, notes, and snippets.

@edenhill
Last active December 14, 2016 16:22
Show Gist options
  • Save edenhill/627f2699aebd3bb1e4346411307e4c44 to your computer and use it in GitHub Desktop.
Save edenhill/627f2699aebd3bb1e4346411307e4c44 to your computer and use it in GitHub Desktop.
rd_kafka_producev() var-arg example
/*!
* Partition (int32_t)
*/
#define RD_KAFKA_V_PARTITION(partition) \
_LRK_TYPECHECK(RD_KAFKA_VTYPE_PARTITION, int32_t, partition), \
(int32_t)partition
/*!
* Message value/payload pointer and length (void *, size_t)
*/
#define RD_KAFKA_V_VALUE(VALUE,LEN) \
_LRK_TYPECHECK2(RD_KAFKA_VTYPE_VALUE, void *, VALUE, size_t, LEN), \
(void *)VALUE, (size_t)LEN
...
err = rd_kafka_producev(rk,
RD_KAFKA_V_TOPIC(topic),
RD_KAFKA_V_VALUE(buf, sizeof(buf)),
RD_KAFKA_V_KEY(key, sizeof(key)),
RD_KAFKA_V_TIMESTAMP(my_timestamp.min),
RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY),
RD_KAFKA_V_OPAQUE(&msgcounter),
RD_KAFKA_V_END);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment