kafka_ex
kafka_ex copied to clipboard
Address inconsistency wrt return type of `latest_offset/3` and expected type of `:offset` options.
This is a follow-up to #183. KafkaEx.latest_offset/3
and KafkaEx.earliest_offset/3
both return type [OffsetResponse.t] | :topic_not_found
. On the other hand, functions like KafkaEx.fetch/3
and KafkaEx.stream/3
take an offset
option that expects an integer offset.
Some options:
- No change
- Modify functions that accept an
offset
parameter to accept[OffsetResponse.t]
OR an integer. - Introduce new functions that accept the array-of-struct argument
- Introduce a new parameter name for the array-of-struct argument
- Change the
latest_offset/3
andearliest_offset/3
functions to return integers. - Introduce a helper function to turn
[OffsetResponse.t]
into a single integer, update the docs to make this usage more clear.
I think option 6 may be the best, followed by 2. 5 breaks the API and is probably not a good idea even though the current API is fairly unintuitive :/ 3 and 4 add complexity to existing functions without really clarifying things much. 2 introduces some incoherence, though it may be the most intuitive option.