swim

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2016 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Alive is the member "alive" state
	Alive = "alive"

	// Faulty is the member "faulty" state
	Faulty = "faulty"

	// Leave is the member "leave" state
	Leave = "leave"

	// Suspect is the memeber "suspect" state
	Suspect = "suspect"
)

Variables

View Source
var (
	// ErrNodeNotReady is returned when a remote request is being handled while the node is not yet ready
	ErrNodeNotReady = errors.New("node is not ready to handle requests")
)

Functions

This section is empty.

Types

type Arg

type Arg struct{}

An Arg is a blank argument used as filler for making TChannel calls that require nothing to be passed to Arg3

type BootstrapOptions

type BootstrapOptions struct {
	// Slice of hosts to bootstrap with, prioritized over provided file
	Hosts []string

	// File containing a JSON array of hosts to bootstrap with
	File string

	// Whether or not gossip should start
	Stopped bool

	// Amount of time before join requests time out
	JoinTimeout time.Duration

	// Minimum number of nodes to join
	JoinSize int

	// Maximum time to attempt joins before joining cluster times out
	MaxJoinDuration time.Duration

	// number of nodes to attempt to join
	ParallelismFactor int
}

BootstrapOptions provides options to bootstrap the node with

type Change

type Change struct {
	Source            string `json:"source"`
	SourceIncarnation int64  `json:"sourceIncarnationNumber"`
	Address           string `json:"address"`
	Incarnation       int64  `json:"incarnationNumber"`
	Status            string `json:"status"`
	// Use util.Timestamp for bi-direction binding to time encoded as
	// integer Unix timestamp in JSON
	Timestamp util.Timestamp `json:"timestamp"`
}

A Change is a change a member to be applied

type ChangeFilteredEvent

type ChangeFilteredEvent struct {
	Change Change
}

A ChangeFilteredEvent is sent when a change has been filtered from the list to be disseminated

type ChangesCalculatedEvent

type ChangesCalculatedEvent struct {
	Changes []Change
}

A ChangesCalculatedEvent is sent when the disseminator generated the list of changes to send in a ping or its response

type ChecksumComputeEvent

type ChecksumComputeEvent struct {
	Duration time.Duration `json:"duration"`
	Checksum uint32        `json:"checksum"`
}

A ChecksumComputeEvent is sent when a the rings checksum is computed

type Endpoint

type Endpoint string

Endpoint is an identifier for an internal swim endpoint

const (
	// PingEndpoint is the identifier for /protocol/ping
	PingEndpoint Endpoint = "ping"

	// PingReqEndpoint is the identifier for /protocol/ping-req
	PingReqEndpoint Endpoint = "ping-req"
)

type EventListener

type EventListener interface {
	HandleEvent(events.Event)
}

An EventListener handles events given to it by the SWIM node. HandleEvent should be thread safe.

type FullSyncEvent

type FullSyncEvent struct {
	Remote         string `json:"remote"`
	RemoteChecksum uint32 `json:"remoteChecksum"`
}

A FullSyncEvent is sent when the disseminator's node issues changes a full sync of the memberlist

type JoinCompleteEvent

type JoinCompleteEvent struct {
	Duration  time.Duration `json:"duration"`
	NumJoined int           `json:"numJoined"`
	Joined    []string      `json:"joined"`
}

A JoinCompleteEvent is sent when a join request to remote node successfully completes

type JoinFailedEvent

type JoinFailedEvent struct {
	Reason JoinFailedReason
	Error  error
}

A JoinFailedEvent is sent when a join request to remote node did not successfully

type JoinFailedReason

type JoinFailedReason string

JoinFailedReason indicates the reason a join failed

const (
	// Error as a JoinFailedReason indicates that the join failed because of an error
	Error JoinFailedReason = "err"

	// Destroyed as a JoinFailedReason indicates that the join failed because ringpop was destroyed during the join
	Destroyed = "destroyed"
)

type JoinReceiveEvent

type JoinReceiveEvent struct {
	Local  string `json:"local"`
	Source string `json:"source"`
}

A JoinReceiveEvent is sent when a join request is received by a node

type JoinTriesUpdateEvent

type JoinTriesUpdateEvent struct {
	Retries int
}

A JoinTriesUpdateEvent is sent when the joiner tries to join a group

type MakeNodeStatusEvent

type MakeNodeStatusEvent struct {
	Status string
}

A MakeNodeStatusEvent is sent when Make[Status] is called on member list

type MaxPAdjustedEvent

type MaxPAdjustedEvent struct {
	OldPCount int `json:"oldPCount"`
	NewPCount int `json:"newPCount"`
}

A MaxPAdjustedEvent occurs when the disseminator adjusts the max propogation count for changes

type Member

type Member struct {
	sync.RWMutex
	Address     string `json:"address"`
	Status      string `json:"status"`
	Incarnation int64  `json:"incarnationNumber"`
}

A Member is a member in the member list

type MemberStats

type MemberStats struct {
	Checksum uint32   `json:"checksum"`
	Members  []Member `json:"members"`
}

MemberStats contains members in a memberlist and the checksum of those members

type MemberlistChangesAppliedEvent

type MemberlistChangesAppliedEvent struct {
	Changes     []Change `json:"changes"`
	OldChecksum uint32   `json:"oldChecksum"`
	NewChecksum uint32   `json:"newChecksum"`
	NumMembers  int      `json:"numMembers"`
}

A MemberlistChangesAppliedEvent contains changes that were applied to the node's memberlist as well as the previous and new checksums and the number of members in the memberlist

type MemberlistChangesReceivedEvent

type MemberlistChangesReceivedEvent struct {
	Changes []Change `json:"changes"`
}

A MemberlistChangesReceivedEvent contains changes received by the node's memberlist, pending application

type Node

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

A Node is a SWIM member

func NewNode

func NewNode(app, address string, channel shared.SubChannel, opts *Options) *Node

NewNode returns a new SWIM node

func (*Node) Address

func (n *Node) Address() string

Address returns the address of the SWIM node

func (*Node) App

func (n *Node) App() string

App returns the node's app

func (*Node) Bootstrap

func (n *Node) Bootstrap(opts *BootstrapOptions) ([]string, error)

Bootstrap joins a node to a cluster. The channel provided to the node must be listening for the bootstrap to complete.

func (*Node) CountReachableMembers

func (n *Node) CountReachableMembers() int

func (*Node) Destroy

func (n *Node) Destroy()

Destroy stops the SWIM protocol and all sub-protocols

func (*Node) Destroyed

func (n *Node) Destroyed() bool

Destroyed returns whether or not the node has been destroyed or node

func (*Node) GetReachableMembers

func (n *Node) GetReachableMembers() []string

func (*Node) Incarnation

func (n *Node) Incarnation() int64

Incarnation returns the incarnation number of the local node

func (*Node) MemberStats

func (n *Node) MemberStats() MemberStats

MemberStats returns the current checksum of the node's memberlist and a slice of the members in the memberlist in lexographically sorted order by address

func (*Node) ProtocolStats

func (n *Node) ProtocolStats() ProtocolStats

ProtocolStats returns stats about the node's SWIM protocol.

func (*Node) Ready

func (n *Node) Ready() bool

Ready returns whether or not the node has bootstrapped fully and is ready for use

func (*Node) RegisterListener

func (n *Node) RegisterListener(l EventListener)

RegisterListener adds a listener that will be sent swim events

func (*Node) Start

func (n *Node) Start()

Start starts the SWIM protocol and all sub-protocols

func (*Node) Stop

func (n *Node) Stop()

Stop stops the SWIM protocol and all sub-protocols

func (*Node) Stopped

func (n *Node) Stopped() bool

Stopped returns whether or not the SWIM protocol is currently running

func (*Node) Uptime

func (n *Node) Uptime() time.Duration

Uptime returns the amount of time the node has been running for

type NodeInterface

type NodeInterface interface {
	Bootstrap(opts *BootstrapOptions) ([]string, error)
	CountReachableMembers() int
	Destroy()
	GetReachableMembers() []string
	MemberStats() MemberStats
	ProtocolStats() ProtocolStats
	Ready() bool
	RegisterListener(l EventListener)
}

type Options

type Options struct {
	SuspicionTimeout  time.Duration
	MinProtocolPeriod time.Duration

	JoinTimeout, PingTimeout, PingRequestTimeout time.Duration

	PingRequestSize int

	RollupFlushInterval time.Duration
	RollupMaxUpdates    int

	BootstrapFile  string
	BootstrapHosts []string

	Logger log.Logger
}

Options to create a SWIM with

type PingReceiveEvent

type PingReceiveEvent struct {
	Local   string   `json:"local"`
	Source  string   `json:"source"`
	Changes []Change `json:"changes"`
}

A PingReceiveEvent is sent when the node receives a ping from a remote node

type PingRequestPingEvent

type PingRequestPingEvent struct {
	Local    string        `json:"local"`
	Source   string        `json:"source"`
	Target   string        `json:"target"`
	Duration time.Duration `json:"duration"`
}

A PingRequestPingEvent is sent when the node sends a ping to the target node at the behest of the source node and receives a response

type PingRequestReceiveEvent

type PingRequestReceiveEvent struct {
	Local   string   `json:"local"`
	Source  string   `json:"source"`
	Target  string   `json:"target"`
	Changes []Change `json:"changes"`
}

A PingRequestReceiveEvent is sent when the node receives a pign request from a remote node

type PingRequestsSendCompleteEvent

type PingRequestsSendCompleteEvent struct {
	Local    string        `json:"local"`
	Target   string        `json:"target"`
	Peers    []string      `json:"peers"`
	Duration time.Duration `json:"duration"`
}

A PingRequestsSendCompleteEvent is sent when the node finished sending ping requests to remote nodes

type PingRequestsSendEvent

type PingRequestsSendEvent struct {
	Local  string   `json:"local"`
	Target string   `json:"target"`
	Peers  []string `json:"peers"`
}

A PingRequestsSendEvent is sent when the node sends ping requests to remote nodes

type PingSendCompleteEvent

type PingSendCompleteEvent struct {
	Local    string        `json:"local"`
	Remote   string        `json:"remote"`
	Changes  []Change      `json:"changes"`
	Duration time.Duration `json:"duration"`
}

A PingSendCompleteEvent is sent when the node finished sending a ping to a remote node

type PingSendEvent

type PingSendEvent struct {
	Local   string   `json:"local"`
	Remote  string   `json:"remote"`
	Changes []Change `json:"changes"`
}

A PingSendEvent is sent when the node sends a ping to a remote node

type ProtocolDelayComputeEvent

type ProtocolDelayComputeEvent struct {
	Duration time.Duration `json:"duration"`
}

A ProtocolDelayComputeEvent is sent when protocol delay is computed during a gossip run

type ProtocolFrequencyEvent

type ProtocolFrequencyEvent struct {
	Duration time.Duration `json:"duration"`
}

A ProtocolFrequencyEvent is sent when a gossip run is finished

type ProtocolStats

type ProtocolStats struct {
	Timing     Timing        `json:"timing"`
	Rate       time.Duration `json:"protocolRate"`
	ClientRate float64       `json:"clientRate"`
	ServerRate float64       `json:"serverRate"`
	TotalRate  float64       `json:"totalRate"`
}

ProtocolStats contains stats about the SWIM Protocol for the node

type RefuteUpdateEvent

type RefuteUpdateEvent struct{}

A RefuteUpdateEvent is sent when a node detects gossip about its own state that needs to be corrected

type RequestBeforeReadyEvent

type RequestBeforeReadyEvent struct {
	Endpoint Endpoint
}

A RequestBeforeReadyEvent is sent if a remote request came in for a ringpop endpoint while ringpop was not ready to process requests

type Status

type Status struct {
	Status string `json:"status"`
}

type Timing

type Timing struct {
	Type     string  `json:"type"`
	Min      int64   `json:"min"`
	Max      int64   `json:"max"`
	Sum      int64   `json:"sum"`
	Variance float64 `json:"variance"`
	Mean     float64 `json:"mean"`
	StdDev   float64 `json:"std_dev"`
	Count    int64   `json:"count"`
	Median   float64 `json:"median"`
	P75      float64 `json:"p75"`
	P95      float64 `json:"p95"`
	P99      float64 `json:"p99"`
	P999     float64 `json:"p999"`
}

Timing contains timing information for the SWIM protocol for the node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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