Change typehints to use Consumer and Producer #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1
PR bumps the version number to 0.4.1.
Previously typehints in namespaces
clj-kafka-x.consumers.simpleandclj-kafka-x.producerused implementation classesKafkaConsumerandKafkaProducer. This causes a problem when trying to test application code with fake/mock implementations of those classes. If passing anything else to those functions using the typehints one gets aClassCastException. One could use Clojure'sproxyor similar mechanisms to try to get around this problem but unfortunately the inner implementation of especiallyKafkaProducermakes mocking them via this manner practically impossible (there are some very nasty ways like JavaAssist but those should be unnecessary).Because of this very reason in Kafka Client library there are interfaces
ConsumerandProducerwhichKafkaConsumerandKafkaProducerimplements.This commit replaces all typehint references to use those two interfaces to allow clean fake/mock implementation usage in tests. This is a non-breaking change and doesn't affect execution or performance characteristics of code in any way when using real
KafkaProducerorKafkaConsumer. Typehint safety is also retained since code is referring to very same public methods as before.After this developers are free to use whatever methods they find necessary to provide mock/fake implementations. They can use ready made
MockConsumerandMockProduceror write their own for example withproxyorreify.