Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
BasicHost changes for introspection #774
BasicHost changes for introspection #774
Changes from 1 commit
b5a2ce9
ece8853
ab66df8
1690b40
0903bf8
b81aecf
691c345
570621a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I don't think we should allow the user to pass in an address. For UX, I would recommend the following:
ListenAddress() string
method to theIntrospector
interface, so we can query it later.Introspector
implementation has aDefaultAddress
, and may use fallback logic if the default listen address is taken. For example, the default address could be:ws://localhost:8096
, and if the port is occupied, we can fall back to trying 8096 + [1,100], trying one by one until we find an available port, or fail entirely. See https://github.com/libp2p/go-libp2p-daemon/blob/b95e77dbfcd186ccf817f51e95f73f9fd5982600/p2pd/main.go#L30-L60 for an example of this logic.ListenAddress() string
method.For a user that wants to set a concrete address, they would construct the concrete implementation via its constructor (which would take a configuration object, that includes the listen addr), and inject that via the
Introspector
option.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.
@raulk
I am not sure I agree. Why shouldn't we allow to user to pass in a address while creating a libp2p node ?
The address is a required by the introspection WS server which is owned by the Host.
The
Introspector
is only responsible for proving a registry for sub-systems & resolving the state when it is asked to. It is not/shouldn't be responsible for serving that state over the wire & hence dosen't need to be bothered with finding a free port which is anyways not a trivial operation & muddles the construction logic of theIntrospector
.I'd like to make
ListenAddress() string
a part of theIntrospectableHost
interface that you've described here. Thego-libp2p-introspection.StartWsServer
method returns the address it was able to bind to(using the same logic as the code that you've linked) which the host then captures & returns viaListenAddress() string
.Wdyt ?
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.
I think I was unclear. We should totally allow passing in a listen address, but not as a dedicated host option. For two reasons:
Users wanting to customise the listen addr of an introspection server, should be able to do that through the endpoint's constructor:
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 duplicates the code in config.NewNode() here.
We can safely assume here that an introspector exists.
However, do we want to allow users to be able to disable introspection ? That decision will affect how we've currently configured introspection on the host.
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.
What does version mean ?
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.
Need to give this a thought.