peers

package module
v0.0.0-...-1fb8944 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 13 Imported by: 0

README

peers

Peers is a library for peer to peer discovery and services in Go.

TODO

  • Peers discovery mechanisms
    • Local:
      • File? Peers exclusive open, write their name if empty, every so often check if that peer is still there?
      • Directory? Each peer writes a file? How to cleanup?
      • In either case, mark as not suitable for production use.
    • GCE managed instance group
    • Kubernetes downward API

Documentation

Overview

Package peers provides peer discovery and services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NodeName  string
	Transport transport.Interface
	Logger    *log.Logger

	// MemberNotify is called from its own goroutine when membership changes
	// occur. Only one call of MemberNotify will be active at a time, so a
	// previous call must return for subsequent calls to be made.
	//
	// MemberNotify will typically call Members to get the current list of
	// members.
	MemberNotify func()

	// Discoverer.Discover is called periodically to obtain out-of-band member
	// discovery. This is useful for connecting new instances to a group of
	// peers.
	Discoverer discovery.Interface
}

Config provides configuration parameters for Peers.

type Peers

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

Peers is the primary object of a peer.

func New

func New(pctx context.Context, cfg Config) (*Peers, error)

func (*Peers) LocalAddr

func (p *Peers) LocalAddr() string

func (*Peers) Members

func (p *Peers) Members() []string

func (*Peers) NumPeers

func (p *Peers) NumPeers() int

func (*Peers) Shutdown

func (p *Peers) Shutdown() error

Directories

Path Synopsis
cmd
internal
maglevhash
Package maglevhash implements the hash function from Maglev, Google's fast load balancer.
Package maglevhash implements the hash function from Maglev, Google's fast load balancer.

Jump to

Keyboard shortcuts

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