swim

package module
v0.0.0-...-f6d5c0c Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

README

swim

This library provides a crude implementation of the SWIM protocol

Documentation

Index

Constants

View Source
const (
	// ASC declares ascending sort order
	ASC = iota
	// DESC declares descending sort order
	DESC
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster interface {
	GetMembers() []*rpc.Node
	Start()
	Stop()
}

Cluster ...

func NewCluster

func NewCluster(config *Config) Cluster

NewCluster ...

type Collection

type Collection interface {
	AddNode(node *rpc.Node)
	DeleteNode(address string)
	GetKeys() []string
	GetNodes() []*rpc.Node
	GetNodeByAddress(address string) (*rpc.Node, bool)
	GetRandomNode() (*rpc.Node, error)
	GetRandomNodes(size int) []*rpc.Node
	GetSampleSize(zscore float64, moe float64) int
	GetSortedNodes(o SortOrder) []*rpc.Node
	Len() int
}

Collection is an unordered grouping of Nodes

func NewCollection

func NewCollection() Collection

NewCollection initializes our collection

type Config

type Config struct {
	Address          string
	BroadcastAddress string
	Seed             *rpc.Node
	RPCPort          uint32
	UDPPort          uint32
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig ...

type Server

type Server interface {
	StartListener(address string, port int) error
	Stop()
	Join(ctx context.Context, in *rpc.JoinMessageInput) (*rpc.JoinMessageOutput, error)
	Leave(ctx context.Context, in *rpc.LeaveMessageInput) (*rpc.LeaveMessageOutput, error)
	Ping(ctx context.Context, in *rpc.PingMessageInput) (*rpc.PingMessageOutput, error)
	PingRequest(ctx context.Context, in *rpc.PingRequestMessageInput) (*rpc.PingMessageOutput, error)
}

Server ...

func NewServer

func NewServer() Server

NewServer ...

type SortOrder

type SortOrder int

SortOrder ...

func (SortOrder) String

func (s SortOrder) String() string

type UDP

type UDP interface {
	GetBroadcastAddress() (net.IP, error)
	SendBroadcast(address string, port int, node *rpc.Node) (int, error)
	StartListener(port int) error
	Stop()
}

UDP ...

func NewUDP

func NewUDP() UDP

NewUDP ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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