-
Notifications
You must be signed in to change notification settings - Fork 265
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
Labels & Policies #99
Comments
Before we even approach this subject, we should agree whether we want to invest or not in first-class userland support for N:1 connections (more than one simultaneous connection to a peer). go-libp2p was built around a policy of "single multiplexed connection per peer", and a departure from that would imply a model breakage, redesign, and significant refactors. My opinion is "yes"; libp2p should be a flexible as possible to allow the developer to define their own connection strategies. Of course there are tradeoffs between one model and the other, but there's no reason why libp2p should limit possibilities for the user. Assuming we decide to go in this direction, connection selection is only one problem to solve. I'm personally not sold on the label approach at all. I think it oversimplifies the problem, and it seems like a poor abstraction for the level of expressiveness we will want to eventually achieve. Labels are arbitrary strings and we'll find them limiting. For example, if a connection is labelled with "ephemeral", it is reasonable to want to enquire the TTL and expiry, which is quite cumbersome with labels. I would nudge towards using language-specific traits/interfaces semantics, which would allow for more expressiveness and extensibility. For example, connections could implement the However, before we go on designing concrete solutions, we should identify everything that proper N:1 requires. Some questions:
|
Ish? go-libp2p does, in fact, support more than one connection per peer, it just doesn't expose this very well. We're already starting to rely on this for transient connections. Basically, I agree with you here but feel more strongly: we not only should support this, we're already using it so we might as well make it first-class.
I agree. In my current proposal, I'm suggesting I don't think we can reliably solve this in the type system. This is where I got stuck during the last libp2p refactor and handling wrapping, upgrades, etc. with types and type assertions gets nasty. There's also the fact that when X is tunneled over Y, X should generally inherit the properties of Y. With properties (I'm just going to call them properties now), composition becomes a lot simpler. Note: properties also allow us to communicate information about connections over the network. |
In general I very much like the idea; the labels can carry semantic information for use from various protocols a components of the system. The main difficulty I see is how those labels get applied. Is it a dial (eg |
I'm expecting labels (properties) to be applied by the transports, connections, etc. at first. I'd also expect the user to be able to "add" labels (e.g., with a |
Background
Currently, connections are generally considered to be equivalent, "global" resources shared by all users of a single libp2p host. However, this isn't always desirable:
Proposal
Introduce a concept of "labels" to libp2p implementations where:
(label, value)
tuples.Examples
Example 1: Transient Connections
Example 2: Service-specific connections
Questions:
Example 3: Priorities
A request (dial, etc.) could specify a priority for labels. E.g., prefer connections that don't require file descriptors, reject transient connections.
Why Labels
So, the simple solution here is to allow the user to pass a bunch of filters in the context (or in some form of policy). E.g., they could pass a filter/comparator to filter/sort transports, addresses, streams, connections, etc.
However, labels let us abstract this away a bit. Instead of having to handle transports, addresses, streams, and connections, the filters/comparators would operate over labeled abstract "objects".
The text was updated successfully, but these errors were encountered: