Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: add StreamExt::chunks_timeout #4695

Merged
merged 13 commits into from Jun 6, 2022

Conversation

jefftt
Copy link
Contributor

@jefftt jefftt commented May 15, 2022

Motivation

Closes #4694. Name is still up for suggestions!

Solution

This is essentially just adds a tokio timer on the futures_util Chunks.
Takes influence from https://github.com/mre/futures-batch which moved off the tokio timer API because it needed sub millisecond precision, however i don't think that's necessary here?

@Darksonn Darksonn added M-time Module: tokio/time A-tokio-stream Area: The tokio-stream crate labels May 16, 2022
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/tests/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/tests/chunks_timeout.rs Outdated Show resolved Hide resolved
@jefftt jefftt requested a review from Darksonn May 24, 2022 18:09
@Darksonn
Copy link
Contributor

The above avoids calling wake_by_ref if both return Pending.

@Darksonn
Copy link
Contributor

You will need to merge master to fix the CI failures.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've asked for some tests below for cases I believe your code currently implements incorrectly. Would you be able to fix them and add the tests? (Or if your code is already correct, just add the test.)

tokio-stream/tests/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/tests/chunks_timeout.rs Show resolved Hide resolved
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good!

tokio-stream/tests/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
@Darksonn
Copy link
Contributor

You still need to merge in master to fix the CI failures. See this page for more info.

@jefftt jefftt requested a review from Darksonn June 4, 2022 02:27
@jefftt jefftt changed the title stream: add StreamExt#chunks_timeout stream: add StreamExt::chunks_timeout Jun 4, 2022
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went though the PR again and found some more comments.

tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext/chunks_timeout.rs Outdated Show resolved Hide resolved
tokio-stream/src/stream_ext.rs Outdated Show resolved Hide resolved
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
@jefftt jefftt requested a review from Darksonn June 6, 2022 13:42
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

@Darksonn Darksonn merged commit 7011a68 into tokio-rs:master Jun 6, 2022
@xmakro
Copy link
Contributor

xmakro commented Sep 13, 2022

@Darksonn Could you please release a new version of tokio-stream that includes this feature? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-stream Area: The tokio-stream crate M-time Module: tokio/time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ChunksTimeout Adapter for StreamExt
3 participants