Summary
Currently, produce_sync is the only produce method that returns a DeliveryReport instead of a DeliveryHandle. All other methods consistently return handles:
| Method |
Returns |
produce_async |
DeliveryHandle |
produce_many_async |
Array<DeliveryHandle> |
produce_sync |
DeliveryReport ← inconsistent |
produce_many_sync |
Array<DeliveryHandle> |
flush_async |
Array<DeliveryHandle> |
flush_sync |
Array<DeliveryHandle> |
Proposal
Change produce_sync to return DeliveryHandle (in its final state) instead of DeliveryReport for full API consistency.
Users who need the report can call handle.create_result.
Breaking Change
This is a breaking change. Code like:
report = producer.produce_sync(topic: 'test', payload: 'data')
puts report.offset
Would need to become:
handle = producer.produce_sync(topic: 'test', payload: 'data')
puts handle.create_result.offset
# or
puts handle.offset # if we delegate offset to the handle
Context
This was identified while fixing documentation inconsistencies in #525 follow-up. The produce_many_sync method was intentionally changed to return handles (instead of reports) in #525 to ensure consistent types in both success and error flows. Applying the same pattern to produce_sync would complete the API consistency.
Summary
Currently,
produce_syncis the only produce method that returns aDeliveryReportinstead of aDeliveryHandle. All other methods consistently return handles:produce_asyncDeliveryHandleproduce_many_asyncArray<DeliveryHandle>produce_syncDeliveryReport← inconsistentproduce_many_syncArray<DeliveryHandle>flush_asyncArray<DeliveryHandle>flush_syncArray<DeliveryHandle>Proposal
Change
produce_syncto returnDeliveryHandle(in its final state) instead ofDeliveryReportfor full API consistency.Users who need the report can call
handle.create_result.Breaking Change
This is a breaking change. Code like:
Would need to become:
Context
This was identified while fixing documentation inconsistencies in #525 follow-up. The
produce_many_syncmethod was intentionally changed to return handles (instead of reports) in #525 to ensure consistent types in both success and error flows. Applying the same pattern toproduce_syncwould complete the API consistency.