Skip to content

Change produce_sync to return DeliveryHandle for API consistency #738

@mensfeld

Description

@mensfeld

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions