-
Notifications
You must be signed in to change notification settings - Fork 964
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
RFC: Expose KeepAlive information to NetworkBehaviour #1717
Conversation
The keep-alive mechanism allows `ProtocolHandler`s to signal whether they still have any use for the underyling connection. Given that `ProtocolHandler`s typically build a hierarchy of `ProtocolHandler`s it is difficult to debug which `ProtocolHandler` is keeping a connection alive. With this commit a `KeepAliveProtocolChange` event is emitted each time the protocol that keeps a connection alive changes. These events are injected into the top level `NetworkBehaviour`. An implementor of the `NetworkBehaviour` can use these events to count the number of connections kept alive per protocol.
I think this approach is doing a bit too much and blurs boundaries. E.g. However, I don't think this approach in general is a real step forward for the keep-alive handling. Let me outline an approach I think may be preferable, though I didn't think through all the details yet:
It would be my hope that an approach along such lines would make it easier to reason about the keep-alive and avoid the pitfalls of correctly implementing Let me know what you think of such an approach. There may obviously be roadblocks I didn't take into account yet. |
I am sorry for the delay. Thank you @romanb for the detailed write-up!
Agreed that the above would simplify the design.
That sounds reasonable. Currently a
Just to make sure I am understanding this correctly, you are actually referring to
How would this information make it from the |
Yes, that was a typo that I now corrected, thanks!
Probably. Since the connection (handler) is fully owned by the background task, connection (handler) events seem to be the only communication mechanism available. |
Update: Currently testing out the above suggestions. Not with a high priority though. |
Within my fork |
With the most recent comment in mind, I am closing this pull request. For anyone willing to continue this effort, I am happy to help. |
The keep-alive mechanism allows
ProtocolHandler
s to signal whetherthey still have any use for the underyling connection. Given that
ProtocolHandler
s typically build a hierarchy ofProtocolHandler
s itis difficult to debug which
ProtocolHandler
is keeping a connectionalive.
With this commit a
KeepAliveProtocolChange
event is emitted each timethe protocol that keeps a connection alive changes. These events are
injected into the top level
NetworkBehaviour
. An implementor of theNetworkBehaviour
can use these events to count the number ofconnections kept alive per protocol.
Exposing this keep alive information would help debugging issues like
#1072 #1698 #1700 and #1398.
Request for comments
As you can tell by the outstanding
TODO
s I am not opening up this pull request in order for it to be merged, but to collect feedback. More concretely I would like to answer the following questions:Is there anyone objecting to the general idea of exposing this information?
Is there anyone objecting (or has an alternative) to the concrete solution of passing the protocol identifier via
KeepAlive
up to theNetworkBehaviour
. Concerns that come to my mind are the additional complexity and the performance impact of passing around bytes.Closes #1701
Closes #1478