static

package
v0.0.0-...-7838e69 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a peer is not found.

Functions

This section is empty.

Types

type Parameter

type Parameter interface {
	// contains filtered or unexported methods
}

Parameter is the interface for service parameters.

func WithLogLevel

func WithLogLevel(logLevel zerolog.Level) Parameter

WithLogLevel sets the log level for the module.

func WithMonitor

func WithMonitor(monitor metrics.PeersMonitor) Parameter

WithMonitor sets the monitor for this module.

func WithPeers

func WithPeers(peers map[uint64]string) Parameter

WithPeers sets the peers for this module.

type Service

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

Service provides a static list of peers.

func New

func New(ctx context.Context, params ...Parameter) (*Service, error)

New creates a new peers provider.

func (*Service) All

func (s *Service) All() map[uint64]*core.Endpoint

All returns all peers.

func (*Service) Peer

func (s *Service) Peer(id uint64) (*core.Endpoint, error)

Peer returns the peer with the given ID.

func (*Service) Suitable

func (s *Service) Suitable(threshold uint32) ([]*core.Endpoint, error)

Suitable returns peers that are suitable given the supplied requirements. At current any peer that is present is considered suitable.

Jump to

Keyboard shortcuts

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