survey

package
v0.0.0-...-055f8da Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	P_MULTICAST = iota + 100
	P_SURVEY
)

Variables

This section is empty.

Functions

func JoinMulticastGroup

func JoinMulticastGroup(network string, ifi *net.Interface, group *net.UDPAddr) (net.PacketConn, error)

JoinMulticastGroup joins the group address group on the provided interface. By default all sources that can cast data to group are accepted.

If ifi == nil, JoinMulticastGroup uses the system-assigned multicast interface. Note that users SHOULD NOT do this because the resulting interface is platform-dependent, and may require special routing config.

func ResolveMulticast

func ResolveMulticast(maddr ma.Multiaddr) (*net.UDPAddr, *net.Interface, error)

func ResolveMulticastInterface

func ResolveMulticastInterface(maddr ma.Multiaddr) (*net.Interface, error)

func WithDistance

func WithDistance(dist uint8) discovery.Option

option for specifying distance when calling FindPeers

Types

type GradualSurveyor

type GradualSurveyor struct {
	// Factor controls how long the GradualSurveyor will wait for
	// peers at each distance. The raw wait time is calculated by
	// evaluating 'distance * factor', before applying min, max &
	// jitter.  Defaults to 1.5.
	Factor float64

	// Min and Max wait durations.  Defaults to 5s and 90s.
	Min, Max time.Duration

	// If true, use the absolute wait durations calculated via min,
	// max and factor.  By default, the final wait time is sampled
	// uniformly from the interval (w/2, w), where 'w' is the wait
	// duration.
	DisableJitter bool
	*Surveyor
}

GradualSurveyor queries a progressively larger subset of the cluster keyspace. It is recommended for bootstrapping large clusters where multicast storms may degrade the service.

See specs/survey.md for details.

func (GradualSurveyor) FindPeers

func (g GradualSurveyor) FindPeers(ctx context.Context, ns string, opt ...discovery.Option) (<-chan peer.AddrInfo, error)

type Surveyor

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

Surveyor discovers peers through a surveyor/respondent multicast protocol.

func New

func New(h host.Host, conn net.PacketConn, opt ...socket.Option) *Surveyor

New surveyor. The supplied PacketConn SHOULD be bound to a multicast group. Use of JoinMulticastGroup to construct conn is RECOMMENDED.

func (*Surveyor) Advertise

func (s *Surveyor) Advertise(ctx context.Context, ns string, opt ...discovery.Option) (ttl time.Duration, err error)

func (*Surveyor) Close

func (s *Surveyor) Close() error

func (*Surveyor) FindPeers

func (s *Surveyor) FindPeers(ctx context.Context, ns string, opt ...discovery.Option) (<-chan peer.AddrInfo, error)

type TranscoderIface

type TranscoderIface struct{}

TranscoderIface decodes an interface name.

func (TranscoderIface) BytesToString

func (it TranscoderIface) BytesToString(b []byte) (string, error)

func (TranscoderIface) StringToBytes

func (it TranscoderIface) StringToBytes(name string) ([]byte, error)

func (TranscoderIface) ValidateBytes

func (it TranscoderIface) ValidateBytes(b []byte) error

Jump to

Keyboard shortcuts

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