Skip to content

add try_produce and rustdoc guidance for Producer<T>#152

Open
josemanuel657 wants to merge 1 commit into
aimdb-dev:mainfrom
josemanuel657:issue_116
Open

add try_produce and rustdoc guidance for Producer<T>#152
josemanuel657 wants to merge 1 commit into
aimdb-dev:mainfrom
josemanuel657:issue_116

Conversation

@josemanuel657

Copy link
Copy Markdown

add try_produce and rustdoc guidance for Producer

Description

Adds Producer::try_produce, a non-blocking fallible push for callers that need a meaningful response to backpressure. Returns the value back via TryProduceError::Full if a bounded buffer is at capacity, or TryProduceError::Closed if the record is shutting down — instead of silently overwriting as produce does.

Extends the internal WriteHandle trait with a default try_push that delegates to push and returns Ok(()), so all existing buffer implementations require no changes. Bounded/non-overwriting buffers override it to return the appropriate error variant.

Also updates the rustdoc on both produce and try_produce with the suggested phrasing and no_run examples so callers can pick the right method without reading the implementation.

Related Issue

Checklist

  • I have read the CONTRIBUTING.md document.
  • My code follows the project's coding standards.
  • I have added tests to cover my changes.
  • All new and existing tests passed (make check).
  • I have updated the documentation accordingly.

Implements Producer::try_produce, which returns the value back via TryProduceError::Full or TryProduceError::Closed instead of silently overwriting, for callers that need a meaningful response to backpressure.

Extends WriteHandle with a default try_push method so existing buffer implementations require no changes. Updates rustdoc on both produce and try_produce with the suggested phrasing and no_run examples so callers can pick the right method without reading the implementation.
@josemanuel657 josemanuel657 requested a review from lxsaah as a code owner June 29, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Non-blocking fallible try_produce for bounded / non-overwriting buffers

1 participant