Bug fixes for sync flush and add_tracker (#91)

* fixes for sync flush and also add_tracker

* added flag for flush
This commit is contained in:
Alex Damian
2018-06-18 17:46:31 -04:00
committed by Matias Fontanini
parent b8f4be5e1b
commit eb46b8808e
2 changed files with 73 additions and 18 deletions

View File

@@ -79,6 +79,19 @@ void flusher_run(BufferedProducer<string>& producer,
producer.flush();
}
void async_flusher_run(BufferedProducer<string>& producer,
int& exit_flag,
int num_flush) {
while (!exit_flag) {
if (producer.get_buffer_size() >= (size_t)num_flush) {
producer.async_flush();
}
this_thread::sleep_for(milliseconds(10));
}
producer.async_flush();
producer.wait_for_acks();
}
void clear_run(BufferedProducer<string>& producer,
condition_variable& clear) {
mutex m;
@@ -377,7 +390,7 @@ TEST_CASE("replay async messages with errors", "[producer][buffered_producer][as
ErrorProducer<string> producer(make_producer_config(),
BufferedProducer<string>::TestParameters{false, true});
producer.set_max_number_retries(num_retries);
thread flusher_thread(flusher_run, ref(producer), ref(exit_flag), 0);
thread flusher_thread(async_flusher_run, ref(producer), ref(exit_flag), 0);
string payload = "Hello world";
producer.produce(MessageBuilder(KAFKA_TOPICS[0]).payload(payload));
this_thread::sleep_for(milliseconds(2000));