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 ¶
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 ¶
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 ¶
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) WithMetrics ¶
WithMetrics turns on metric collection in discoery.
type OnUpdatedPeers ¶
type Option ¶
type Option func(*options)
Option is a function that configures Discovery Parameters
func WithAdvertise ¶
func WithAdvertise() Option
func WithOnPeersUpdate ¶
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