discovery

package
v0.15.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

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

Discovery combines advertise and discover services and allows to store discovered nodes. TODO: The code here gets horribly hairy, so we should refactor this at some point

func NewDiscovery

func NewDiscovery(
	params *Parameters,
	h host.Host,
	d discovery.Discovery,
	tag string,
	opts ...Option,
) (*Discovery, error)

NewDiscovery constructs a new discovery.

func (*Discovery) Advertise

func (d *Discovery) Advertise(ctx context.Context)

Advertise is a utility function that persistently advertises a service through an Advertiser. TODO: Start advertising only after the reachability is confirmed by AutoNAT

func (*Discovery) Discard

func (d *Discovery) Discard(id peer.ID) bool

Discard removes the peer from the peer set and rediscovers more if soft peer limit is not reached. Reports whether peer was removed with bool.

func (*Discovery) Peers

func (d *Discovery) Peers(ctx context.Context) ([]peer.ID, error)

Peers provides a list of discovered peers in the given topic. If Discovery hasn't found any peers, it blocks until at least one peer is found.

func (*Discovery) Start

func (d *Discovery) Start(context.Context) error

func (*Discovery) Stop

func (d *Discovery) Stop(context.Context) error

func (*Discovery) WithMetrics

func (d *Discovery) WithMetrics() error

WithMetrics turns on metric collection in discoery.

type OnUpdatedPeers

type OnUpdatedPeers func(peerID peer.ID, isAdded bool)

type Option

type Option func(*options)

Option is a function that configures Discovery Parameters

func WithAdvertise added in v0.14.0

func WithAdvertise() Option

func WithOnPeersUpdate added in v0.11.0

func WithOnPeersUpdate(f OnUpdatedPeers) Option

WithOnPeersUpdate chains OnPeersUpdate callbacks on every update of discovered peers list.

type Parameters

type Parameters struct {
	// PeersLimit defines the soft limit of FNs to connect to via discovery.
	// Set 0 to disable.
	PeersLimit uint
	// AdvertiseInterval is a interval between advertising sessions.
	// NOTE: only full and bridge can advertise themselves.
	AdvertiseInterval time.Duration
}

Parameters is the set of Parameters that must be configured for the Discovery module

func DefaultParameters

func DefaultParameters() *Parameters

DefaultParameters returns the default Parameters' configuration values for the Discovery module

func (*Parameters) Validate

func (p *Parameters) Validate() error

Validate validates the values in Parameters

Jump to

Keyboard shortcuts

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