kafka_ex icon indicating copy to clipboard operation
kafka_ex copied to clipboard

Address inconsistency wrt return type of `latest_offset/3` and expected type of `:offset` options.

Open dantswain opened this issue 8 years ago • 0 comments

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:

  1. No change
  2. Modify functions that accept an offset parameter to accept [OffsetResponse.t] OR an integer.
  3. Introduce new functions that accept the array-of-struct argument
  4. Introduce a new parameter name for the array-of-struct argument
  5. Change the latest_offset/3 and earliest_offset/3 functions to return integers.
  6. 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.

dantswain avatar Jan 20 '17 23:01 dantswain