-
Notifications
You must be signed in to change notification settings - Fork 144
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
Replace broadcast channels and refactor websocket streaming #955
Conversation
Not to hold this up, but have you considered using tokio-tungstenite? You're mixing concurrency execution engines. Also, maybe consider using a feature to support parallel implementations for async-std, tokio, and maybe even smol. It's not a huge deal, but someday, someone might want to use an embedded Filecoin implementation... 😉 |
Obviously it's a nitpick, so it shouldn't hold up the merge. But, some more thoughts on the crate feature. Usually, I'd say, "it's better to pick one", because it'd simplify testing, but also, in my experience, it shouldn't be that big a deal since Rust has so many correctness guarantees. "Fearless concurrency", after all. Further, when there are non-obvious issues with concurrency, it'd be very nice to have a parallel implementation, just to for debugging and benchmarking purposes. |
It's fine because of the tokio 1.0 support in async-std. I don't like mixing these either, but Tokio has the broadcast channel that works by far the best for our need. This is not a PR we are pulling in quickly and going to explore options more before pulling in. Also, we use async-std as our runtime, so I'd rather not use more Tokio things than needed.
The feature gets applied to everything in the workspace, I just don't want the case where tokio support is removed and it's forgotten to remove the flag from crates that never used/ needed. Do I understand your point correctly? |
Honestly, there are other reasons to want a parallel Tokio implementation. Tokio has gotten better and has more momentum and adoption in the broader Rust ecosystem. If you look into
Not quite, I mean, for supporting both at the same time, just behind separate feature flags, like, for example, in these projects (it's somewhat common in the Rust community for libraries). For an example that comes to mind, see: https://github.com/hecrj/iced/blob/8d882d787e6b7fd7c2435f42f82933e2ed904edf/Cargo.toml#L38-L45 That said, I'd scope the feature to just the two, async-std and tokio, for now. |
We've obviously considered Tokio, but we have had a better experience with async-std as a default, and isn't a priority to switch.
Ah yeah I see what you're saying, and there isn't a solid reason for a binary like ours to support both. It makes sense for that and other libs because they want to allow users to use whatever runtime they want with it, but our priority is on the actual |
I'll take it. That said, I wouldn't shut the door on this question just yet. There are certainly use cases, such as for a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else looks great. Just two small changes i noted:
FIrst thing to send back to a ChainNotify is {"jsonrpc":"2.0","result":<CHANNEL NUMBER>,"id":0}
.
Second thing to send back is a HeadChange::Current event.
Then all other HeadChange events that come through the subscription.
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links