monitor

package
v0.0.0-...-23d3fd2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer encapsulates a libp2p host that dials peers.

func NewDialer

func NewDialer(h host.Host, conf *config.Monitor) (*Dialer, error)

NewDialer initializes a new dialer based on the given configuration.

func (*Dialer) StartDialing

func (d *Dialer) StartDialing(ctx context.Context, dialQueue *queue.FIFO[peer.AddrInfo], resultsQueue *queue.FIFO[Result])

StartDialing enters an endless loop and consumes dial jobs from the dial queue and publishes its result on the results queue until it is told to stop or the dial queue was closed.

type Result

type Result struct {
	DialerID string

	// The dialed peer
	Peer peer.AddrInfo

	// If error is set the peer was not dialable
	Error error

	// The above error transferred to a known error
	DialError string

	// When was the dial started
	DialStartTime time.Time

	// When did this crawl end
	DialEndTime time.Time
}

Result captures data that is gathered from pinging a single peer.

func (*Result) DialDuration

func (r *Result) DialDuration() time.Duration

DialDuration returns the time it took to dial the peer

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

The Scheduler handles the scheduling and managing of

a) dialers - They consume a queue of peer address information, visit them and publish their results
             on a separate results queue. This results queue is consumed by this scheduler and further
             processed

func NewScheduler

func NewScheduler(conf *config.Monitor, dbc *db.DBClient) (*Scheduler, error)

NewScheduler initializes a new libp2p host and scheduler instance.

func (*Scheduler) StartMonitoring

func (s *Scheduler) StartMonitoring(ctx context.Context) error

StartMonitoring starts the configured amount of dialers and fills the dial queue with peers that are due to be dialed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL