in_random: use new input chunk registration calls
@@ -50,6 +50,8 @@ static int in_random_collect(struct flb_input_instance *i_ins,
int fd;
int ret;
uint64_t val;
+ msgpack_packer mp_pck;
+ msgpack_sbuffer mp_sbuf;
struct flb_in_random_config *ctx = in_context;
if (ctx->samples == 0) {
@@ -74,19 +76,21 @@ static int in_random_collect(struct flb_input_instance *i_ins,
close(fd);
}
- /* Mark the start of a 'buffer write' operation */
- flb_input_buf_write_start(i_ins);
+ /* Initialize local msgpack buffer */
+ msgpack_sbuffer_init(&mp_sbuf);
+ msgpack_packer_init(&mp_pck, &mp_sbuf, msgpack_sbuffer_write);
- msgpack_pack_array(&i_ins->mp_pck, 2);
- flb_pack_time_now(&i_ins->mp_pck);
- msgpack_pack_map(&i_ins->mp_pck, 1);
+ /* Pack data */
+ msgpack_pack_array(&mp_pck, 2);
+ flb_pack_time_now(&mp_pck);
+ msgpack_pack_map(&mp_pck, 1);
- msgpack_pack_str(&i_ins->mp_pck, 10);
- msgpack_pack_str_body(&i_ins->mp_pck, "rand_value", 10);
- msgpack_pack_uint64(&i_ins->mp_pck, val);
-
- flb_input_buf_write_end(i_ins);
+ msgpack_pack_str(&mp_pck, 10);
+ msgpack_pack_str_body(&mp_pck, "rand_value", 10);
+ msgpack_pack_uint64(&mp_pck, val);
+ flb_input_chunk_append_raw(i_ins, NULL, 0, mp_sbuf.data, mp_sbuf.size);
+ msgpack_sbuffer_destroy(&mp_sbuf);
ctx->samples_count++;
return 0;
