add try_produce and rustdoc guidance for Producer<T>#152
Open
josemanuel657 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaTryProduceError::Fullif a bounded buffer is at capacity, orTryProduceError::Closedif the record is shutting down — instead of silently overwriting asproducedoes.Extends the internal
WriteHandletrait with a defaulttry_pushthat delegates topushand returnsOk(()), 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
produceandtry_producewith the suggested phrasing andno_runexamples so callers can pick the right method without reading the implementation.Related Issue
try_producefor bounded / non-overwriting buffers #116Checklist
make check).