/** * Enqueue op for app. Convenience function */ void rd_kafka_op_app_fmt (rd_kafka_q_t *rkq, rd_kafka_op_type_t type, rd_kafka_toppar_t *rktp, rd_kafka_resp_err_t err, const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); rd_vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); rd_kafka_op_app(rkq, type, RD_KAFKA_OP_F_FREE, rktp, err, rd_strdup(buf), strlen(buf), NULL); }
/** * Propagate an error event to the application on a specific queue. * \p optype should be RD_KAFKA_OP_ERR for generic errors and * RD_KAFKA_OP_CONSUMER_ERR for consumer errors. */ void rd_kafka_q_op_err (rd_kafka_q_t *rkq, rd_kafka_op_type_t optype, rd_kafka_resp_err_t err, int32_t version, const char *fmt, ...) { va_list ap; char buf[2048]; va_start(ap, fmt); rd_vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); rd_kafka_op_app_reply(rkq, optype, err, version, rd_strdup(buf), strlen(buf)); }
/** * sprintf a message in rko->rko_payload (typically error string) */ void rd_kafka_op_sprintf (rd_kafka_op_t *rko, const char *fmt, ...) { va_list ap; char buf[2048]; va_start(ap, fmt); rd_vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); rd_kafka_assert(NULL, !rko->rko_payload); rko->rko_payload = rd_strdup(buf); rko->rko_len = strlen(buf); rko->rko_flags |= RD_KAFKA_OP_F_FREE; rko->rko_free_cb = rd_free; }
/** * Propogate an error event to the application. * If no error_cb has been set by the application the error will * be logged instead. */ void rd_kafka_op_err (rd_kafka_t *rk, rd_kafka_resp_err_t err, const char *fmt, ...) { va_list ap; char buf[2048]; va_start(ap, fmt); rd_vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if (rk->rk_conf.error_cb) rd_kafka_op_app_reply(&rk->rk_rep, RD_KAFKA_OP_ERR, err, 0, rd_strdup(buf), strlen(buf)); else rd_kafka_log_buf(rk, LOG_ERR, "ERROR", buf); }
/** * Propagate an error event to the application on a specific queue. * \p optype should be RD_KAFKA_OP_ERR for generic errors and * RD_KAFKA_OP_CONSUMER_ERR for consumer errors. */ void rd_kafka_q_op_err (rd_kafka_q_t *rkq, rd_kafka_op_type_t optype, rd_kafka_resp_err_t err, int32_t version, rd_kafka_toppar_t *rktp, int64_t offset, const char *fmt, ...) { va_list ap; char buf[2048]; rd_kafka_op_t *rko; va_start(ap, fmt); rd_vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); rko = rd_kafka_op_new(optype); rko->rko_version = version; rko->rko_err = err; rko->rko_u.err.offset = offset; rko->rko_u.err.errstr = rd_strdup(buf); if (rktp) rko->rko_rktp = rd_kafka_toppar_keep(rktp); rd_kafka_q_enq(rkq, rko); }