Documentation ¶
Overview ¶
Package discovery provides a basic memberlist integration.
Index ¶
- Variables
- type ClusterEvent
- type Discovery
- func (d *Discovery) FindMemberByID(id uint64) (Member, error)
- func (d *Discovery) FindMemberByName(name string) (Member, error)
- func (d *Discovery) GetCoordinator() Member
- func (d *Discovery) GetMembers() []Member
- func (d *Discovery) IsCoordinator() bool
- func (d *Discovery) Join() (int, error)
- func (d *Discovery) LocalNode() *memberlist.Node
- func (d *Discovery) NumMembers() int
- func (d *Discovery) Rejoin(peers []string) (int, error)
- func (d *Discovery) Shutdown() error
- func (d *Discovery) Start() error
- func (d *Discovery) SubscribeNodeEvents() chan *ClusterEvent
- type Member
Constants ¶
This section is empty.
Variables ¶
var ErrMemberNotFound = errors.New("member not found")
ErrMemberNotFound indicates that the requested member could not be found in the member list.
var UptimeSeconds = stats.NewInt64Counter()
UptimeSeconds is number of seconds since the server started.
Functions ¶
This section is empty.
Types ¶
type ClusterEvent ¶
type ClusterEvent struct { Event memberlist.NodeEventType NodeName string NodeAddr net.IP NodePort uint16 NodeMeta []byte // Metadata from the delegate for this node. }
ClusterEvent is a single event related to node activity in the memberlist. The Node member of this struct must not be directly modified.
func ToClusterEvent ¶ added in v0.4.0
func ToClusterEvent(e memberlist.NodeEvent) *ClusterEvent
func (*ClusterEvent) MemberAddr ¶
func (c *ClusterEvent) MemberAddr() string
type Discovery ¶
type Discovery struct { ClusterEvents chan *ClusterEvent // contains filtered or unexported fields }
Discovery is a structure that encapsulates memberlist and provides useful functions to utilize it.
func New ¶
New creates a new memberlist with a proper configuration and returns a new Discovery instance along with it.
func (*Discovery) FindMemberByID ¶
FindMemberByID finds and returns an alive member.
func (*Discovery) FindMemberByName ¶
FindMemberByName finds and returns an alive member.
func (*Discovery) GetCoordinator ¶
GetCoordinator returns the oldest node in the memberlist.
func (*Discovery) GetMembers ¶
GetMembers returns a full list of known alive nodes.
func (*Discovery) IsCoordinator ¶
IsCoordinator returns true if the caller is the coordinator node.
func (*Discovery) Join ¶
Join is used to take an existing Memberlist and attempt to Join a cluster by contacting all the given hosts and performing a state sync. Initially, the Memberlist only contains our own state, so doing this will cause remote nodes to become aware of the existence of this node, effectively joining the cluster.
func (*Discovery) LocalNode ¶
func (d *Discovery) LocalNode() *memberlist.Node
LocalNode is used to return the local Node
func (*Discovery) NumMembers ¶
func (*Discovery) Shutdown ¶
Shutdown will stop any background maintenance of network activity for this memberlist, causing it to appear "dead". A leave message will not be broadcasted prior, so the cluster being left will have to detect this node's Shutdown using probing. If you wish to more gracefully exit the cluster, call Leave prior to shutting down.
This method is safe to call multiple times.
func (*Discovery) SubscribeNodeEvents ¶
func (d *Discovery) SubscribeNodeEvents() chan *ClusterEvent
type Member ¶
Member represents a node in the cluster.
func NewMemberFromMetadata ¶ added in v0.4.0
func (Member) CompareByID ¶ added in v0.4.0
CompareByID returns true if two members denote the same member in the cluster.
func (Member) CompareByName ¶ added in v0.4.0
CompareByName returns true if the two members has the same name in the cluster. This function is intended to redirect the requests to the partition owner.