introspector.go 1.19 KB
Newer Older
1 2 3 4 5
package introspection

import (
	"io"

tavit ohanian's avatar
tavit ohanian committed
6
	"gitlab.dms3.io/p2p/go-p2p-core/introspection/pb"
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
)

// Introspector is the interface to be satisfied by components that are capable
// of spelunking the state of the system, and representing in accordance with
// the introspection schema.
//
// It's very rare to build a custom implementation of this interface;
// it exists mostly for mocking. In most cases, you'll end up using the
// default introspector.
//
// Introspector implementations are usually injected in introspection endpoints
// to serve the data to clients, but they can also be used separately for
// embedding or testing.
//
// Experimental.
type Introspector interface {
	io.Closer

	// FetchRuntime returns the runtime information of the system.
	FetchRuntime() (*pb.Runtime, error)

	// FetchFullState returns the full state cross-cut of the running system.
	FetchFullState() (*pb.State, error)

	// EventChan returns the channel where all eventbus events are dumped,
	// decorated with their corresponding event metadata, ready to send over
	// the wire.
	EventChan() <-chan *pb.Event

	// EventMetadata returns the metadata of all events known to the
	// Introspector.
	EventMetadata() []*pb.EventType
}