peermonitor

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

peermonitor is a package for watching peers on a pub sub channel

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventPeerJoin

func NewEventPeerJoin(p peer.ID) events.Event

NewEventPeerJoin creates a new EventPeerJoin event

func NewEventPeerLeave

func NewEventPeerLeave(p peer.ID) events.Event

NewEventPeerLeave creates a new EventPeerLeave event

Types

type EventPeerJoin

type EventPeerJoin struct {
	Peer peer.ID
}

EventPeerJoin Is an event triggered when a peer joins the channel

type EventPeerLeave

type EventPeerLeave struct {
	Peer peer.ID
}

EventPeerLeave Is an event triggered when a peer leave the channel

type Interface

type Interface interface {
	events.EmitterInterface

	// Start Starts watching the topic for new joins or leaves
	Start(ctx context.Context) func()

	// Stop Stops the watcher
	Stop()

	// GetPeers Lists peers currently present on the topic
	GetPeers() []peer.ID

	// HasPeer Checks if a peer is present on the topic
	HasPeer(id peer.ID) bool

	// Started Returns whether the peer monitor has been started
	Started() bool
}

Interface Watches for peers on the pub sub, emits messages on join/leave

func NewPeerMonitor

func NewPeerMonitor(ctx context.Context, ipfs coreapi.CoreAPI, topic string, options *NewPeerMonitorOptions) Interface

NewPeerMonitor Creates a new PeerMonitor instance

type NewPeerMonitorOptions

type NewPeerMonitorOptions struct {
	Start        *bool
	PollInterval *time.Duration
	Logger       *zap.Logger
}

NewPeerMonitorOptions Options for creating a new PeerMonitor instance

Jump to

Keyboard shortcuts

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