This repository was archived by the owner on Sep 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
(Long-lived branch): Introspection capability for go-libp2p #112
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c72a961
Introspection types for core (#107)
aarshkshah1992 a448afc
introspection: rename package, rm ListenAddr() from interface. (#111)
raulk c109bc7
add an introspection.Endpoint interface.
raulk 7513ae8
network: add Opened timestamp to network.Stat.
raulk fab9d25
introspection.proto: fix stream ID type.
raulk 6d6f828
introspection.proto: make transport ID a string.
raulk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
|
||
"github.com/libp2p/go-libp2p-core/connmgr" | ||
"github.com/libp2p/go-libp2p-core/event" | ||
"github.com/libp2p/go-libp2p-core/introspection" | ||
"github.com/libp2p/go-libp2p-core/network" | ||
"github.com/libp2p/go-libp2p-core/peer" | ||
"github.com/libp2p/go-libp2p-core/peerstore" | ||
|
@@ -73,3 +74,16 @@ type Host interface { | |
// EventBus returns the hosts eventbus | ||
EventBus() event.Bus | ||
} | ||
|
||
// IntrospectableHost is implemented by Host implementations that are | ||
// introspectable, that is, that may have introspection capability. | ||
type IntrospectableHost interface { | ||
// Introspector the introspector, or nil if one hasn't been registered. With | ||
// it, the call can register data providers, and can fetch introspection | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the caller* |
||
// data. | ||
Introspector() introspection.Introspector | ||
|
||
// IntrospectionEndpoint returns the introspection endpoint, or nil if one | ||
// hasn't been registered. | ||
IntrospectionEndpoint() introspection.Endpoint | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Package introspection is EXPERIMENTAL. It is subject to heavy change, and it | ||
// WILL change. For now, it is the simplest implementation to power the | ||
// proof-of-concept of the libp2p introspection framework. | ||
// | ||
// Package introspect contains the abstract skeleton of the introspection system | ||
// of go-libp2p. It holds the introspection data schema, and the primitives that | ||
// allow subsystems to register data providers, and clients to fetch the current | ||
// state of the system. | ||
package introspection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package introspection | ||
|
||
// Endpoint is the interface to be implemented by introspection | ||
// endpoints/servers. | ||
// | ||
// An introspection endpoint exposes introspection data over the wire via a | ||
// protocol and data format, e.g. WebSockets with Protobuf. | ||
type Endpoint interface { | ||
// Start starts the introspection endpoint. It must only be called once, and | ||
// once the server is started, subsequent calls made without first calling | ||
// Close will error. | ||
Start() error | ||
|
||
// Close stops the introspection endpoint. Calls to Close on an already | ||
// closed endpoint, or an unstarted endpoint, must noop. | ||
Close() error | ||
|
||
// ListenAddrs returns the listen addresses of this endpoint. | ||
ListenAddrs() []string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package introspection | ||
|
||
import introspection_pb "github.com/libp2p/go-libp2p-core/introspection/pb" | ||
|
||
// ProtoVersion is the current version of the introspection protocol. | ||
const ProtoVersion uint32 = 1 | ||
|
||
// EXPERIMENTAL. Introspector allows other sub-systems/modules to register | ||
// metrics/data providers AND also enables clients to fetch the current state of | ||
// the system. | ||
// | ||
// Introspector implementations are usually injected in introspection endpoints | ||
// (e.g. the default WebSocket endpoint) to serve the data to clients, but they | ||
// can also be used separately for embedding or testing. | ||
type Introspector interface { | ||
// EXPERIMENTAL. RegisterDataProviders allows sub-systems/modules to | ||
// register callbacks that supply introspection data. | ||
RegisterDataProviders(p *DataProviders) error | ||
|
||
// EXPERIMENTAL. FetchFullState returns the full state of the system, by | ||
// calling all known data providers and returning a merged cross-cut of the | ||
// running system. | ||
FetchFullState() (*introspection_pb.State, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
PB = $(wildcard *.proto) | ||
GO = $(PB:.proto=.pb.go) | ||
|
||
all: $(GO) | ||
|
||
%.pb.go: %.proto | ||
protoc --proto_path=$(PWD):$(PWD)/../..:$(GOPATH)/src --gogofaster_out=Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:. $< | ||
|
||
clean: | ||
rm -f *.pb.go | ||
rm -f *.go |
Oops, something went wrong.
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.
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.
returns the*