cluster

package
v0.0.0-...-36a4cef Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceType is the type used to advertise the cluster to join
	ServiceType = "_bobcaygeon._tcp"
)

Variables

This section is empty.

Functions

func FilterMembers

func FilterMembers(memberType NodeType, list *memberlist.Memberlist) []*memberlist.Node

FilterMembers filters down the memberlist to return only nodes of the given type

func FilterMembersByFn

func FilterMembersByFn(filter MemberFilter, list *memberlist.Memberlist) []*memberlist.Node

FilterMembersByFn provides more flexibility in using a filtering function

func SearchForCluster

func SearchForCluster() *zeroconf.ServiceEntry

SearchForCluster searches for a cluster to join

Types

type Delegate

type Delegate struct {
	MetaData *NodeMeta
}

Delegate handles memberlist events

func (Delegate) GetBroadcasts

func (Delegate) GetBroadcasts(overhead, limit int) [][]byte

GetBroadcasts is called when user data messages can be broadcast.

func (Delegate) LocalState

func (Delegate) LocalState(join bool) []byte

LocalState is used for a TCP Push/Pull. This is sent to the remote side in addition to the membership information.

func (Delegate) MergeRemoteState

func (Delegate) MergeRemoteState(buf []byte, join bool)

MergeRemoteState is invoked after a TCP Push/Pull.

func (Delegate) NodeMeta

func (d Delegate) NodeMeta(limit int) []byte

NodeMeta is used to retrieve meta-data about the current node when broadcasting an alive message.

func (Delegate) NotifyMsg

func (Delegate) NotifyMsg([]byte)

NotifyMsg is called when a user-data message is received.

type EventDelegate

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

EventDelegate handles the delgate functions from the memberlist

func NewEventDelegate

func NewEventDelegate(d []memberlist.EventDelegate) *EventDelegate

NewEventDelegate instantiates a new EventDelegate struct

func (*EventDelegate) NotifyJoin

func (ed *EventDelegate) NotifyJoin(node *memberlist.Node)

NotifyJoin is invoked when a node is detected to have joined. The Node argument must not be modified.

func (*EventDelegate) NotifyLeave

func (ed *EventDelegate) NotifyLeave(node *memberlist.Node)

NotifyLeave is invoked when a node is detected to have left. The Node argument must not be modified.

func (*EventDelegate) NotifyUpdate

func (ed *EventDelegate) NotifyUpdate(node *memberlist.Node)

NotifyUpdate is invoked when a node is detected to have updated, usually involving the meta data. The Node argument must not be modified.

type MemberFilter

type MemberFilter func(*memberlist.Node) bool

MemberFilter function used to filter the list down

type NodeMeta

type NodeMeta struct {
	RtspPort int
	APIPort  int
	RaftPort int
	NodeType NodeType
}

NodeMeta is metadata passed to other members about this node

func DecodeNodeMeta

func DecodeNodeMeta(nodeMeta []byte) NodeMeta

DecodeNodeMeta decodes node meta data from bytes into something useful

type NodeType

type NodeType int

NodeType describes what type of role this node has in the cluster

const (
	// Music this node is responsible for music
	Music NodeType = iota
	// Mgmt this node is responsible for management
	Mgmt
	// Frontend this is a node for controlling front proxy
	Frontend
)

Jump to

Keyboard shortcuts

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