Documentation ¶
Index ¶
- Constants
- Variables
- func AttemptHeal(node *Node, target string) ([]string, error)
- func DoThenWaitFor(f func(), er events.EventRegistrar, t interface{})
- type AddJoinListEvent
- type AttemptHealEvent
- type BootstrapOptions
- type Change
- type ChangeFilteredEvent
- type ChangesCalculatedEvent
- type ChecksumComputeEvent
- type DiscoHealEvent
- type Endpoint
- type FullSyncEvent
- type HealResponse
- type JoinCompleteEvent
- type JoinFailedEvent
- type JoinFailedReason
- type JoinReceiveEvent
- type JoinTriesUpdateEvent
- type ListenerFunc
- type MakeNodeStatusEvent
- type MaxPAdjustedEvent
- type Member
- type MemberStats
- type MemberlistChangesAppliedEvent
- type MemberlistChangesReceivedEvent
- type Node
- func (n *Node) Address() string
- func (n *Node) App() string
- func (n *Node) Bootstrap(opts *BootstrapOptions) ([]string, error)
- func (n *Node) CountReachableMembers() int
- func (n *Node) Destroy()
- func (n *Node) Destroyed() bool
- func (n *Node) GetChecksum() uint32
- func (n *Node) GetReachableMembers() []string
- func (n *Node) HasChanges() bool
- func (n *Node) Incarnation() int64
- func (n *Node) MemberStats() MemberStats
- func (n *Node) ProtocolStats() ProtocolStats
- func (n *Node) Ready() bool
- func (n *Node) RegisterListener(l events.EventListener)
- func (n *Node) Start()
- func (n *Node) Stop()
- func (n *Node) Stopped() bool
- func (n *Node) Uptime() time.Duration
- type NodeInterface
- type OmitReverseFullSyncEvent
- type Options
- type PingReceiveEvent
- type PingRequestPingEvent
- type PingRequestReceiveEvent
- type PingRequestSendErrorEvent
- type PingRequestsSendCompleteEvent
- type PingRequestsSendEvent
- type PingSendCompleteEvent
- type PingSendEvent
- type ProtocolDelayComputeEvent
- type ProtocolFrequencyEvent
- type ProtocolStats
- type RedundantReverseFullSyncEvent
- type RefuteUpdateEvent
- type RequestBeforeReadyEvent
- type StartReverseFullSyncEvent
- type StateTimeouts
- type Status
- type Timing
Constants ¶
const ( // Alive is the member "alive" state Alive = "alive" // Suspect is the member "suspect" state Suspect = "suspect" // Faulty is the member "faulty" state Faulty = "faulty" // Leave is the member "leave" state Leave = "leave" // Tombstone is the member "tombstone" state Tombstone = "tombstone" )
Variables ¶
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 ¶
func AttemptHeal ¶ added in v0.5.0
AttemptHeal attempts to heal a partition between the node and the target.
Be mindfull that calling this function will not result in a heal when there are nodes that need to be reincarated to take precedence over the faulty declarations that occur during a network partition. A cluster may therefore need multiple calls to this function with some time in between to heal.
Check out ringpop-common/docs for a full description of the algorithm.
func DoThenWaitFor ¶ added in v0.5.0
func DoThenWaitFor(f func(), er events.EventRegistrar, t interface{})
DoThenWaitFor executes a function and then waits for a specific type of event to occur. This function shouldn't be used outside tests because there is no way to unsubscribe the event handler.
Often we want to execute some code and then wait for an event be emitted due to the code being executed. However in order to not miss the event we must first register an event handler before we can execute the code: - register listener that signals we can continue on receiving the correct event; - execute the code that will lead to an event being emitted; - wait for the continue signal.
This can be quite hard to follow. Ideally we want it to look like - execute the code that will lead to an event being emitted; - and then wait for a specific event.
This function helps with making the code read like the latter.
Types ¶
type AddJoinListEvent ¶ added in v0.5.0
AddJoinListEvent is sent when a join list is added to the membership
type AttemptHealEvent ¶ added in v0.5.0
type AttemptHealEvent struct{}
AttemptHealEvent is sent when the healer is triggered
type BootstrapOptions ¶
type BootstrapOptions struct { // The DiscoverProvider resolves a list of bootstrap hosts. DiscoverProvider discovery.DiscoverProvider // Whether or not gossip should be started immediately after a successful // bootstrap. Stopped bool // Amount of time before individual join requests time out. JoinTimeout time.Duration // Minimum number of nodes to join to satisfy a bootstrap. JoinSize int // Maximum time to attempt joins before the entire bootstrap process times // out. MaxJoinDuration time.Duration // A higher ParallelismFactor increases the number of nodes that a // bootstrapping node will attempt to reach out to in order to satisfy // `JoinSize` (the number of nodes that will be contacted at a time is // `ParallelismFactor * JoinSize`). ParallelismFactor int }
BootstrapOptions is a configuration struct passed to Node.Bootstrap.
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"` Tombstone bool `json:"tombstone,omitempty"` // 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"` OldChecksum uint32 `json:"oldchecksum"` }
A ChecksumComputeEvent is sent when a the rings checksum is computed
type DiscoHealEvent ¶ added in v0.5.0
type DiscoHealEvent struct{}
DiscoHealEvent is sent when the discover provider healer attempts to heal a partition
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 HealResponse ¶ added in v0.5.0
HealResponse contains a list of nodes where healing was attempted
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 ¶
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 ListenerFunc ¶ added in v0.3.0
The ListenerFunc type is an adapter to allow the use of ordinary functions as EventListeners.
func (ListenerFunc) HandleEvent ¶ added in v0.3.0
func (f ListenerFunc) HandleEvent(e events.Event)
HandleEvent calls f(e).
type MakeNodeStatusEvent ¶
type MakeNodeStatusEvent struct {
Status string
}
A MakeNodeStatusEvent is sent when Make[Status] is called on member list
type MaxPAdjustedEvent ¶
A MaxPAdjustedEvent occurs when the disseminator adjusts the max propagation 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 ¶
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) 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 ¶
CountReachableMembers returns the number of members currently in this node's membership list that aren't faulty.
func (*Node) Destroy ¶
func (n *Node) Destroy()
Destroy stops the SWIM protocol and all sub-protocols.
func (*Node) GetChecksum ¶ added in v0.3.0
GetChecksum returns the current checksum of the node's memberlist.
func (*Node) GetReachableMembers ¶
GetReachableMembers returns a slice of members currently in this node's membership list that aren't faulty.
func (*Node) HasChanges ¶ added in v0.3.0
HasChanges reports whether Node has changes to disseminate.
func (*Node) Incarnation ¶
Incarnation returns the incarnation number of the 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) RegisterListener ¶
func (n *Node) RegisterListener(l events.EventListener)
RegisterListener adds an EventListener to the node. When a swim event e is emitted, l.HandleEvent(e) is called for every registered listener l. Attention, all listeners are called synchronously. Be careful with registering blocking and other slow calls.
type NodeInterface ¶
type NodeInterface interface { Bootstrap(opts *BootstrapOptions) ([]string, error) CountReachableMembers() int Destroy() GetChecksum() uint32 GetReachableMembers() []string MemberStats() MemberStats ProtocolStats() ProtocolStats Ready() bool RegisterListener(l events.EventListener) }
NodeInterface specifies the public-facing methods that a SWIM Node implements.
type OmitReverseFullSyncEvent ¶ added in v0.5.0
type OmitReverseFullSyncEvent struct {
Target string `json:"target"`
}
OmitReverseFullSyncEvent is sent when a node omits the reverse full sync prodedure because there are already the max number of reverse full sync processes running.
type Options ¶
type Options struct { StateTimeouts StateTimeouts MinProtocolPeriod time.Duration JoinTimeout, PingTimeout, PingRequestTimeout time.Duration PingRequestSize int RollupFlushInterval time.Duration RollupMaxUpdates int MaxReverseFullSyncJobs int // When started, the partition healing algorithm attempts a partition heal // every PartitionHealPeriod with a probability of: // PartitionHealBaseProbabillity / # Nodes in discoverProvider. // // When in a 100 node cluster BaseProbabillity = 3 and Period = 30s, // every 30 seconds a node will have a probability of 3/100 to start the // partition healing procedure. This means that for the entire cluster // the discover provider receives 6 calls per minute on average. PartitionHealPeriod time.Duration PartitionHealBaseProbabillity float64 Clock clock.Clock }
Options is a configuration struct passed the NewNode constructor.
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 PingRequestSendErrorEvent ¶ added in v0.3.0
type PingRequestSendErrorEvent struct { Local string `json:"local"` Target string `json:"target"` Peers []string `json:"peers"` Peer string `json:"peer"` }
A PingRequestSendErrorEvent is sent when the node can't get a response sending ping requests to remote nodes
type PingRequestsSendCompleteEvent ¶
type PingRequestsSendCompleteEvent struct { Local string `json:"local"` Target string `json:"target"` Peers []string `json:"peers"` Peer string `json:"peer"` 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 ¶
A ProtocolDelayComputeEvent is sent when protocol delay is computed during a gossip run
type ProtocolFrequencyEvent ¶
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 RedundantReverseFullSyncEvent ¶ added in v0.5.0
type RedundantReverseFullSyncEvent struct {
Target string `json:"target"`
}
RedundantReverseFullSyncEvent is sent when no new changes were added due to the reverse full sync.
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 StartReverseFullSyncEvent ¶ added in v0.5.0
type StartReverseFullSyncEvent struct {
Target string `json:"target"`
}
A StartReverseFullSyncEvent is sent when a node starts the reverse full sync procedure
type StateTimeouts ¶ added in v0.4.0
type StateTimeouts struct { // Suspect is the timeout it takes a node in suspect mode to transition to faulty Suspect time.Duration // Faulty is the timeout it takes a node in faulty mode to transition to tombstone Faulty time.Duration // Tombstone is the timeout it takes a node in tombstone mode to be evicted Tombstone time.Duration }
StateTimeouts contains the configured timeouts for every state before transitioning to the new state
type Status ¶
type Status struct {
Status string `json:"status"`
}
Status contains a status string of the response from a handler.
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
Source Files ¶
- disseminator.go
- events.go
- gossip.go
- handlers.go
- heal_partition.go
- heal_via_discover_provider.go
- join_delayer.go
- join_handler.go
- join_sender.go
- member.go
- memberlist.go
- memberlist_iter.go
- node.go
- ping_handler.go
- ping_request_handler.go
- ping_request_sender.go
- ping_sender.go
- state_transitions.go
- stats.go
- test_utils.go
- update_rollup.go