Documentation ¶
Index ¶
- Constants
- type ArrivalIntervals
- type ArrivalWindow
- type Delta
- type Digest
- type FailureDetector
- func (fd *FailureDetector) PeerStatus(endpoint string) PeerStatus
- func (fd *FailureDetector) PeerStatusAtTimestamp(endpoint string, timestampNano uint64) PeerStatus
- func (fd *FailureDetector) RemovePeer(endpoint string)
- func (fd *FailureDetector) Report(endpoint string)
- func (fd *FailureDetector) ReportWithTimestamp(endpoint string, timestampNano uint64)
- type Gossiper
- func (g *Gossiper) Addrs(includeLocal bool) []string
- func (g *Gossiper) BindAddr() string
- func (g *Gossiper) CheckLiveness()
- func (g *Gossiper) Close() error
- func (g *Gossiper) Lookup(addr string, key string) (string, bool)
- func (g *Gossiper) OnMessage(b []byte, fromAddr string) error
- func (g *Gossiper) RandomDownPeer() (string, bool)
- func (g *Gossiper) RandomUpPeer() (string, bool)
- func (g *Gossiper) Seed(seeds []string)
- func (g *Gossiper) SendDigestRequest(addr string) error
- func (g *Gossiper) UpdateLocal(key string, value string)
- type Packet
- type Peer
- func (p *Peer) Addr() string
- func (p *Peer) Deltas(version uint64) []Delta
- func (p *Peer) Digest() Digest
- func (p *Peer) Equal(o *Peer) bool
- func (p *Peer) Expiry() time.Time
- func (p *Peer) Lookup(key string) (PeerEntry, bool)
- func (p *Peer) SetStatusDown(expiry time.Time)
- func (p *Peer) SetStatusUp()
- func (p *Peer) Status() PeerStatus
- func (p *Peer) UpdateLocal(key string, value string)
- func (p *Peer) UpdateRemote(key string, value string, version uint64)
- func (p *Peer) Version() uint64
- type PeerEntry
- type PeerMap
- func (m *PeerMap) Addrs(includeLocal bool) []string
- func (m *PeerMap) ApplyDelta(delta Delta)
- func (m *PeerMap) ApplyDigest(digest Digest)
- func (m *PeerMap) Deltas(addr string, version uint64) []Delta
- func (m *PeerMap) Digest(addr string) Digest
- func (m *PeerMap) DownPeers() []string
- func (m *PeerMap) Lookup(addr string, key string) (PeerEntry, bool)
- func (m *PeerMap) PeersEqual(o *PeerMap) bool
- func (m *PeerMap) RemoveExpiredPeers() []string
- func (m *PeerMap) SetStatusDown(addr string, expiry time.Time)
- func (m *PeerMap) SetStatusUp(addr string)
- func (m *PeerMap) UpdateLocal(key string, value string)
- func (m *PeerMap) Version(addr string) uint64
- type PeerStatus
- type Transport
- type UDPTransport
Constants ¶
const ( PeerStatusUp = PeerStatus(1) PeerStatusDown = PeerStatus(2) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrivalIntervals ¶
type ArrivalIntervals struct {
// contains filtered or unexported fields
}
ArrivalIntervals tracks the intervals in a circular buffer.
func NewArrivalIntervals ¶
func NewArrivalIntervals(sampleSize int) *ArrivalIntervals
func (*ArrivalIntervals) Add ¶
func (ai *ArrivalIntervals) Add(interval uint64)
func (*ArrivalIntervals) Mean ¶
func (ai *ArrivalIntervals) Mean() float64
type ArrivalWindow ¶
type ArrivalWindow struct {
// contains filtered or unexported fields
}
func NewArrivalWindow ¶
func NewArrivalWindow(gossipInterval uint64, sampleSize int) *ArrivalWindow
func (*ArrivalWindow) Add ¶
func (w *ArrivalWindow) Add(timestampNano uint64)
func (*ArrivalWindow) Phi ¶
func (w *ArrivalWindow) Phi(timestampNano uint64) float64
type Delta ¶
func (Delta) MarshalLogObject ¶
func (e Delta) MarshalLogObject(enc zapcore.ObjectEncoder) error
type Digest ¶
func (Digest) MarshalLogObject ¶
func (p Digest) MarshalLogObject(enc zapcore.ObjectEncoder) error
type FailureDetector ¶
type FailureDetector struct {
// contains filtered or unexported fields
}
FailureDetector is a failure detector that detects down nodes based on incoming heartbeats.
This implements the paper "The Phi Accrual Failure Detector".
func NewFailureDetector ¶
func NewFailureDetector(gossipInterval uint64, sampleSize int, convictThreshold float64) *FailureDetector
func (*FailureDetector) PeerStatus ¶
func (fd *FailureDetector) PeerStatus(endpoint string) PeerStatus
func (*FailureDetector) PeerStatusAtTimestamp ¶
func (fd *FailureDetector) PeerStatusAtTimestamp(endpoint string, timestampNano uint64) PeerStatus
func (*FailureDetector) RemovePeer ¶
func (fd *FailureDetector) RemovePeer(endpoint string)
func (*FailureDetector) Report ¶
func (fd *FailureDetector) Report(endpoint string)
func (*FailureDetector) ReportWithTimestamp ¶
func (fd *FailureDetector) ReportWithTimestamp(endpoint string, timestampNano uint64)
type Gossiper ¶
type Gossiper struct {
// contains filtered or unexported fields
}
func NewGossiper ¶
func (*Gossiper) CheckLiveness ¶
func (g *Gossiper) CheckLiveness()
func (*Gossiper) RandomDownPeer ¶
func (*Gossiper) RandomUpPeer ¶
func (*Gossiper) SendDigestRequest ¶
func (*Gossiper) UpdateLocal ¶
type Packet ¶
type Packet struct { // Buf has the raw contents of the packet. Buf []byte // From has the address of the peer. This is an actual net.Addr so we // can expose some concrete details about incoming packets. From net.Addr }
Packet is used to provide some metadata about incoming packets from peers over a packet connection, as well as the packet payload.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer represents the state of a peer.
func NewPeer ¶
NewPeer returns a new peer with the given address, with a version of 0 to indicate it has no known state.
func (*Peer) Deltas ¶
Deltas returns all entries whos versions exceed the given version, ordered by version.
Note the deltas are ordered by version since the full all deltas may not be sent and we can't have gaps in versions.
func (*Peer) SetStatusDown ¶
SetStatusDown sets the status to down and sets the expiry of when the peer should be removed if it hasen't come up.
func (*Peer) SetStatusUp ¶
func (p *Peer) SetStatusUp()
func (*Peer) Status ¶
func (p *Peer) Status() PeerStatus
func (*Peer) UpdateLocal ¶
UpdateLocal updates the peer when it is owned by the local node. This increments the peers version so it is propagated around the cluster. If the value is unchanged, the version isn't updated (to avoid propagating redundant data).
func (*Peer) UpdateRemote ¶
UpdateRemote updates the peer from an update from a remote node. If the local version of that entry is greater than the new version, the update is discarded.
type PeerMap ¶
type PeerMap struct {
// contains filtered or unexported fields
}
PeerMap contains this nodes view of all known peers in the cluster.
Note this is thread safe.
func NewPeerMap ¶
func (*PeerMap) Addrs ¶
Addrs returns the addresses of the up peers known by this node. If includeLocal is true the local node is included, otherwise it isn't.
func (*PeerMap) ApplyDelta ¶
func (*PeerMap) ApplyDigest ¶
func (*PeerMap) PeersEqual ¶
func (*PeerMap) RemoveExpiredPeers ¶
func (*PeerMap) SetStatusUp ¶
func (*PeerMap) UpdateLocal ¶
UpdateLocal updates an entery in this nodes local peer.
type PeerStatus ¶
type PeerStatus int
type Transport ¶
type Transport interface { // WriteTo is a packet-oriented interface that fires off the given // payload to the given address in a connectionless fashion. WriteTo(b []byte, addr string) error // BindAddr returns the address the transport listener is bound to. Note // this may be different from the configured bind addr if the system chooses // the addr (such as using a port of 0). BindAddr() string // Shutdown is called when gossip is shutting down; this gives the // transport a chance to clean up any listeners. Shutdown() error }
Transport is an interface for a best-effort packet oriented transport.
type UDPTransport ¶
type UDPTransport struct {
// contains filtered or unexported fields
}
UDPTransport is a Transport implementation using UDP.
func (*UDPTransport) BindAddr ¶
func (t *UDPTransport) BindAddr() string
func (*UDPTransport) Shutdown ¶
func (t *UDPTransport) Shutdown() error