-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: coordinating Tokio 1.0 with the availability of Stream in std #2870
Comments
I don't know what the current thought is, but there was an idea that the futures crate could start transparently reexporting std's Stream when being built against a suitable version to avoid forcing a big migration. |
See also rust-lang/futures-rs#2207 |
@taiki-e thanks for that. My understanding is that it would still technically be a breaking change. My gut is that I would rather start a 1.0 stability guarantee on strong footing. |
For exhaustiveness, I think there that there's a third option: a six month MSRV policy can take effect well after a 1.0 is released. I'm not convinced that a Tokio 1.0 release needs to be coupled to a six month MSRV policy at release. This is something that can be added retroactively. |
@carllerche Yeah, that's technically breaking change. AFAIK, theoretically, if the signature of the std FYI: I've created a demo of how that's implemented: https://github.com/taiki-e/futures-compat-experiment |
Perhaps another idea for this would be to use a (disabled by default) feature flag that includes the version number: like |
Related: rust-lang/rust#79023 |
As of this comment, If Assuming that
Once |
The stream::Iter utility uses the coop helper which is not public. Instead, we could hard limit the number of items returned to 32 then yield. It is not ideal but is temporary. cc @LucioFranco |
This change removes all references to `Stream` from within the `tokio` crate and moves them into a new `tokio-stream` crate. Most types have had their `impl Stream` removed as well in-favor of their inherent methods. Closes #2870
This change removes all references to `Stream` from within the `tokio` crate and moves them into a new `tokio-stream` crate. Most types have had their `impl Stream` removed as well in-favor of their inherent methods. Closes #2870
## Issue Addressed resolves #2129 resolves #2099 addresses some of #1712 unblocks #2076 unblocks #2153 ## Proposed Changes - Updates all the dependencies mentioned in #2129, except for web3. They haven't merged their tokio 1.0 update because they are waiting on some dependencies of their own. Since we only use web3 in tests, I think updating it in a separate issue is fine. If they are able to merge soon though, I can update in this PR. - Updates `tokio_util` to 0.6.2 and `bytes` to 1.0.1. - We haven't made a discv5 release since merging tokio 1.0 updates so I'm using a commit rather than release atm. **Edit:** I think we should merge an update of `tokio_util` to 0.6.2 into discv5 before this release because it has panic fixes in `DelayQueue` --> PR in discv5: sigp/discv5#58 ## Additional Info tokio 1.0 changes that required some changes in lighthouse: - `interval.next().await.is_some()` -> `interval.tick().await` - `sleep` future is now `!Unpin` -> tokio-rs/tokio#3028 - `try_recv` has been temporarily removed from `mpsc` -> tokio-rs/tokio#3350 - stream features have moved to `tokio-stream` and `broadcast::Receiver::into_stream()` has been temporarily removed -> `tokio-rs/tokio#2870 - I've copied over the `BroadcastStream` wrapper from this PR, but can update to use `tokio-stream` once it's merged tokio-rs/tokio#3384 Co-authored-by: realbigsean <[email protected]>
Currently, Tokio uses the
Stream
trait provided byfutures-core
. There is an ongoing effort to define aStream
trait within std. Tokio is currently aiming to release 1.0 by the end of the year. Given the Rust release cadence,Stream
may not be available instd
on the stable channel by the end of the year.If
Stream
is not available on the Rust stable channel by the end of the year, we have two options.Stream
becomes available in std.Stream
usage from Tokio until 6 months after it becomes available instd
(due to the proposed MSRV policy).Stream usage
Currently,
Stream
is implemented in Tokio by:mpsc::Receiver
broadcast::Receiver
signal::Signal
Tokio also provides a
tokio::stream
module containing a number of useful stream utilities. A list can be found here.Removing the
Stream
dependencyIf
Stream
is removed from thetokio
crate, it can be placed temporarily in thetokio-util
crate. This crate is not intended to reach 1.0 by the end of year.Stream
usage within Tokio is already isolated via thestream
feature flag. While useful, it is not a critical dependency.Removing
Stream
fromtokio
would impact the discoverability of the utilities. This could be mitigated by including an emptytokio::stream
module with documentation explaining where to find the utilities.Adding
Stream
post 1.0Adding
Stream
after an initial 1.0 release would take at least 6 months given the currently proposed MSRV policy (#2718). According to the policy, 1.x releases are permitted to increase the MSRV, but must support all Rust versions released in the past 6 months.Next steps
I will leave this open-ended for now as we collect comments. We can then decide on the direction we want to take.
The text was updated successfully, but these errors were encountered: