linkedin / li-apache-kafka-clients

li-apache-kafka-clients is a wrapper library for the Apache Kafka vanilla clients. It provides additional features such as large message support and auditing to the Java producer and consumer in the open source Apache Kafka.
BSD 2-Clause "Simplified" License
131 stars 52 forks source link

Add constructor that allows injecting a Consumer #58

Closed ambroff closed 5 years ago

ambroff commented 7 years ago

I'm working on a change to a library that uses LiKafkaConsumerImpl and I found myself wanting to add an integration test that tested that integration. I wanted to do that by providing a mock Consumer<byte[], byte[]> so that my integration test didn't actually need Kafka, but unfortunately there wasn't any way to inject a consumer object.

This change just adds a couple of new constructors so that clients can provide their own Consumer<byte[], byte[]> if necessary.

becketqin commented 7 years ago

Ideally we don't want to expose such injection as a public interface for testing purpose. I am wondering what was the test trying to do?

ambroff commented 7 years ago

It's not just for testing purposes. Someone might want to provide their own custom implementation for some other reason. I see no downside to having these additional constructors in the interface.