discovery

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package discovery provides service advertisement and peer discovery interfaces for dep2p.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advertiser

type Advertiser interface {
	// Advertise advertises a service
	Advertise(ctx context.Context, ns string, opts ...Option) (time.Duration, error)
}

Advertiser is an interface for advertising services

type Discoverer

type Discoverer interface {
	// FindPeers discovers peers providing a service
	FindPeers(ctx context.Context, ns string, opts ...Option) (<-chan peer.AddrInfo, error)
}

Discoverer is an interface for peer discovery

type Discovery

type Discovery interface {
	Advertiser
	Discoverer
}

Discovery is an interface that combines service advertisement and peer discovery

type Option

type Option func(opts *Options) error

DiscoveryOpt is a single discovery option.

func Limit

func Limit(limit int) Option

Limit is an option that provides an upper bound on the peer count for discovery

func TTL

func TTL(ttl time.Duration) Option

TTL is an option that provides a hint for the duration of an advertisement

type Options

type Options struct {
	Ttl   time.Duration
	Limit int

	// Other (implementation-specific) options
	Other map[interface{}]interface{}
}

DiscoveryOpts is a set of discovery options.

func (*Options) Apply

func (opts *Options) Apply(options ...Option) error

Apply applies the given options to this DiscoveryOpts

Jump to

Keyboard shortcuts

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