-
Notifications
You must be signed in to change notification settings - Fork 999
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
Add helpers to create a transport with secio and mplex/yamux #735
Comments
An important motivation for this change is that we want to reserve the right to break the API of the underlying combinators, and it would be nicer if we could avoid breaking everyone's code in the process. |
What API do you have in mind for this? let t = CommonTransport::new()
.with_upgrade(secio::SecioConfig::new(key))
.with_upgrade(yamux::Config::default()) |
That's the difficult part of this issue! Using |
This is ugly and rigid on current API. Very unfriendly! |
@daogangtang as a user, what would the ideal API look like? |
We wish multiple with_upgrade(), one by one, as above. |
The approach with
More specifically, I would go for something like that: /// Can add support for new protocols, and maybe break backwards compatibility by removing deprecated protocols.
pub fn build_general_transport(k: SecioKeyPair) -> impl Transport {
build_tcp_ws_secio_mplex_yamux(k)
}
/// Guaranteed to never change.
pub fn build_tcp_ws_secio_mplex_yamux(k: SecioKeyPair) -> impl Transport { ... } In other words, we would provide one transport for the "general" case, and one transport for the common situations. If the user needs something more fine-grained, they can always fall back to using combinators. |
Similarly I would automatically add a timeout to the |
Most people just want secio, mplex and yamux. We should add a helper that easily creates a transport like that.
The text was updated successfully, but these errors were encountered: