net

package
v1.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTL = time.Hour * 8766

Variables

This section is empty.

Functions

func WithPeerID

func WithPeerID(id peer.ID) discovery.Option

Types

type Env

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

func New

func New(t Timer) *Env

func (Env) NewDiscovery

func (env Env) NewDiscovery(info peer.AddrInfo, t Topology) discovery.Discovery

func (Env) NewHost

func (env Env) NewHost(ctx context.Context, opt ...config.Option) (host.Host, error)

NewHost returns a new host with a random identity and the default in-process transport.

type InfoSlice

type InfoSlice []*peer.AddrInfo

func (InfoSlice) Len

func (is InfoSlice) Len() int

func (InfoSlice) Less

func (is InfoSlice) Less(i, j int) bool

func (InfoSlice) Swap

func (is InfoSlice) Swap(i, j int)

type Namespace

type Namespace interface {
	Peers() InfoSlice
	Upsert(*peer.AddrInfo, *discovery.Options) time.Duration
}

type NamespaceProvider

type NamespaceProvider interface {
	Load(ns string) (Namespace, bool)
	LoadOrCreate(ns string) Namespace
}

type SelectAll

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

func (SelectAll) Select

func (s SelectAll) Select(_ context.Context, ns Namespace, opts *discovery.Options) (InfoSlice, error)

func (SelectAll) SetDefaultOptions

func (SelectAll) SetDefaultOptions(*discovery.Options) error

type SelectRandom

type SelectRandom struct {
	Src rand.Source
	// contains filtered or unexported fields
}

func (*SelectRandom) Select

func (SelectRandom) SetDefaultOptions

func (SelectRandom) SetDefaultOptions(*discovery.Options) error

type SelectRing

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

func (SelectRing) Select

func (s SelectRing) Select(_ context.Context, ns Namespace, opts *discovery.Options) (InfoSlice, error)

func (SelectRing) SetDefaultOptions

func (SelectRing) SetDefaultOptions(*discovery.Options) error

type Timer

type Timer interface {
	After(d time.Duration, callback func()) clock.CancelFunc
}

type Topology

type Topology interface {
	SetDefaultOptions(*discovery.Options) error
	Select(context.Context, Namespace, *discovery.Options) (InfoSlice, error)
}

Topology selects peeers from the environment.

Jump to

Keyboard shortcuts

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