예제 #1
0
/**
 * NOTE: 'offsets' may be NULL, see official documentation.
 */
rd_kafka_resp_err_t
rd_kafka_commit (rd_kafka_t *rk,
                 const rd_kafka_topic_partition_list_t *offsets, int async) {
        rd_kafka_cgrp_t *rkcg;
	rd_kafka_resp_err_t err;
	rd_kafka_q_t *repq = NULL;
	rd_kafka_replyq_t rq = RD_KAFKA_NO_REPLYQ;

        if (!(rkcg = rd_kafka_cgrp_get(rk)))
                return RD_KAFKA_RESP_ERR__UNKNOWN_GROUP;

        if (!async)
                repq = rd_kafka_q_new(rk);

        if (!async) 
		rq = RD_KAFKA_REPLYQ(repq, 0);
 
        err = rd_kafka_commit0(rk, offsets, NULL, rq, NULL, NULL);

        if (!err && !async) {
		err = rd_kafka_q_wait_result(repq, RD_POLL_INFINITE);
		rd_kafka_q_destroy(repq);
        }

	return err;
}
예제 #2
0
/**
 * NOTE: 'offsets' may be NULL, see official documentation.
 */
rd_kafka_resp_err_t
rd_kafka_commit (rd_kafka_t *rk,
                 const rd_kafka_topic_partition_list_t *offsets, int async) {
        rd_kafka_cgrp_t *rkcg;
	rd_kafka_resp_err_t err;
	rd_kafka_q_t *tmpq = NULL;

        if (!(rkcg = rd_kafka_cgrp_get(rk)))
                return RD_KAFKA_RESP_ERR__UNKNOWN_GROUP;

        if (!async)
                tmpq = rd_kafka_q_new(rk);

        err = rd_kafka_commit0(rk, offsets, async ? NULL : tmpq, NULL);

        if (!async) {
		err = rd_kafka_q_wait_result(tmpq, RD_POLL_INFINITE);
                rd_kafka_q_destroy(tmpq);
        } else {
                err = RD_KAFKA_RESP_ERR_NO_ERROR;
        }

	return err;
}