-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: introduce libp2p-stream
#5027
Conversation
I've pushed an initial implementation. It was actually easier than I expected. Still need to review it myself once I've got fresher eyes though! It also doesn't have any documentation yet although there is quite a bit I want to say about the design in regards to backpressure for example. |
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.
This is great! The implementation is simple, the example is even simpler.
I have some suggestions but overall, from an architecture perspective, this looks good to me.
@mxinden This is actually getting into a state where I am considering to make it a regular |
Sounds good to me! |
stream::Behaviour
libp2p-stream
The idea is that a rendezvous channel will wake up the connection handler and allows us to directly close the connection if nothing else is using it.
@mxinden: I've update this PR to get rid of the I decided that I don't want to implement any form of connection keep-alive. Instead, requesting a new stream should simply attempt to establish a new connection. I think that is overall more useful! But without the Curious to hear what you think of this design! |
@mxinden I decided to also move |
@mxinden I'd suggest to merge this with a failing |
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.
Looking forward for this to land! I expect this to be useful for many, especially those implementing a protocol on top of libp2p for the first time.
@rkuhn I resolved your comments to allow this to merge! :) |
For a while now, `rust-libp2p` provided the `request-response` abstraction which makes it easy for users to build request-response based protocols without having to implement a `NetworkBehaviour` themselves. This PR introduces an alpha version of `libp2p-stream`: a `NetworkBehaviour` that directly gives access to negotiated streams. In addition to complementing `request-response`, `libp2p-stream` also diverges in its design from the remaining modules by offering a clonable `Control` that provides `async` functions. Resolves: libp2p#4457. Pull-Request: libp2p#5027.
For a while now, `rust-libp2p` provided the `request-response` abstraction which makes it easy for users to build request-response based protocols without having to implement a `NetworkBehaviour` themselves. This PR introduces an alpha version of `libp2p-stream`: a `NetworkBehaviour` that directly gives access to negotiated streams. In addition to complementing `request-response`, `libp2p-stream` also diverges in its design from the remaining modules by offering a clonable `Control` that provides `async` functions. Resolves: libp2p#4457. Pull-Request: libp2p#5027.
Description
For a while now,
rust-libp2p
provided therequest-response
abstraction which makes it easy for users to build request-response based protocols without having to implement aNetworkBehaviour
themselves. This PR introduces an alpha version oflibp2p-stream
: aNetworkBehaviour
that directly gives access to negotiated streams.In addition to complementing
request-response
,libp2p-stream
also diverges in its design from the remaining modules by offering a clonableControl
that providesasync
functions.Resolves: #4457.
Notes & open questions
Change checklist