-
Notifications
You must be signed in to change notification settings - Fork 984
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
Shrink Swarm
API and empower NetworkBehaviour
s?
#3314
Comments
The I think reaching a decision here is important so we know which direction to move into. |
Related: #3305. Our examples are confusing users because we showcase a linear flow based on Our way of expressing state machines are That is good because it makes modular pieces that you can actually use in our application. Unfortunately, it is also a bit clunky because our current custom derive is an all or nothing solution. If we force all user logic to be a I don't have a definite answer to how to best do this at the moment but one option we should explore is splitting up the |
I wonder if we can get away with designing them such that the "policy" behaviour (i.e. the user code) doesn't need to compose our "mechanism" behaviours (i.e. the Libraries are most useful if they provide mechanism (performing an action such as dctur) but are ignorant about policy (when to perform the action). Afaik, we currently always perform dcutr as soon as we dial a peer through a relay. "Always" is a policy that may or may not be what the user wants. |
This issue actually spans further: Currently, almost1 all Footnotes
|
Is there a use-case where one would not want a
👍
That would be nice indeed. |
It would be a way of encouraging users towards implementing their networking logic as |
Thank you for starting this discussion @thomaseizinger! I feel like this proposal is kinda going into the opposite direction than previous changes on our Swarm API. We have recently encouraged users to rather implement their logic on top of the swarm, e.g. with changes like #2100 and #2784. The purpose of NetworkBehaviour (and related traits) is currently to implement protocols that we speak with remote peers, including a handler for connections, etc. As the tutorial nicely puts it:
I always found that easy to understand, and also the swarm as the interface that wraps the Transport and NetworkBehaviour and implements protocol-independent must-have functionalities. (We could maybe do better with our naming though.) If we can simplify the |
Thanks for the comment @elenaf9 ! I don't see it as such a drastic step "backwards". #2784 was about handling behaviour events outside of Perhaps it is a bit too early for this proposal as we don't have the necessary infrastructure yet for behaviours to collaborate amongst each other which is what we'd need. Long-term, I think we should keep this design in mind. Polling the Short-term, a meaningful step might be to strive for enum SwarmEvent {
FromBehaviour(TOut),
FromSwarm(FromSwarm)
} |
Prior issues:
listener
callback methods #3040I'd like to propose that we adopt the following design:
Swarm
apart from access to the innerNetworkBehaviour
.SwarmEvent
in favor of only emittingNetworkBehaviour::OutEvent
as part ofStream::poll_next
NetworkBehaviour
s with all capabilities required to do what users can currently do via theSwarm
APIThe benefits of this design are:
NetworkBehaviour
s, see Extend NetworkBehaviourAction to add and remove listeners #3291 as an exampleFromSwarm
andSwarmEvent
are very similarSwarm
is just a "runtime" and plugins have full control over its stateSome ideas on how we can achieve this:
NetworkBehaviour
s to manage connections #3254.Control
behaviour that exposes public functions for dialing nodes and listening on addresses.Info
orStats
behaviour that tracks connected peers, external addresses etcLog
behaviour that emits nice log messages for anything that happens within theSwarm
The text was updated successfully, but these errors were encountered: