mlist

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelWarn  = "WARN"
	LogLevelError = "ERROR"
	LogLevelInfo  = "INFO"
)

Variables

This section is empty.

Functions

func GetGRPCPortFromBindPort added in v2.6.0

func GetGRPCPortFromBindPort(bindPort int) int

func GetRaftPortFromBindPort added in v2.6.0

func GetRaftPortFromBindPort(bindPort int) int

func NewOptions

func NewOptions(opts ...Option) *memberlist.Config

Types

type Broadcast

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

func (*Broadcast) Finished

func (b *Broadcast) Finished()

func (*Broadcast) Invalidates

func (b *Broadcast) Invalidates(other memberlist.Broadcast) bool

func (*Broadcast) Message

func (b *Broadcast) Message() []byte

type Delegate

type Delegate struct {
	sync.RWMutex

	State      map[string]int64
	Broadcasts *memberlist.TransmitLimitedQueue
	LocalNode  *memberlist.Node
	// contains filtered or unexported fields
}

func NewDelegate

func NewDelegate(inboundMsgCh chan<- []byte) *Delegate

func (*Delegate) BindMqttServer

func (d *Delegate) BindMqttServer(server *mqtt.Server)

func (*Delegate) Broadcast

func (d *Delegate) Broadcast(data []byte)

Broadcast broadcast to everyone including yourself

func (*Delegate) GetBroadcasts

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

func (*Delegate) InitBroadcasts

func (d *Delegate) InitBroadcasts(list *memberlist.Memberlist)

func (*Delegate) LocalState

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

func (*Delegate) MergeRemoteState

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

func (*Delegate) NodeMeta

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

func (*Delegate) NotifyMsg

func (d *Delegate) NotifyMsg(msg []byte)

func (*Delegate) Stop

func (d *Delegate) Stop()

type Membership

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

func New

func New(config *config.Cluster, inboundMsgCh chan<- []byte) *Membership

func (*Membership) BindMqttServer

func (m *Membership) BindMqttServer(server *mqtt.Server)

func (*Membership) Broadcast

func (m *Membership) Broadcast(msg []byte)

func (*Membership) EventChan

func (m *Membership) EventChan() <-chan *mb.Event

func (*Membership) GetNodeByIP

func (m *Membership) GetNodeByIP(ipAddr net.IP) *memberlist.Node

func (*Membership) Join added in v2.3.7

func (m *Membership) Join(existing []string) (int, error)

Join joins an existing Serf cluster. Returns the number of nodes successfully contacted. The returned error will be non-nil only in the case that no nodes could be contacted. The format of an existing node is nodename/ip:port or ip:port

func (*Membership) Leave added in v2.3.7

func (m *Membership) Leave() error

Leave gracefully exits the cluster.

func (*Membership) LocalAddr

func (m *Membership) LocalAddr() string

func (*Membership) LocalName

func (m *Membership) LocalName() string

func (*Membership) LocalNode

func (m *Membership) LocalNode() *memberlist.Node

func (*Membership) Members

func (m *Membership) Members() []mb.Member

func (*Membership) NumMembers

func (m *Membership) NumMembers() int

func (*Membership) SendToNode

func (m *Membership) SendToNode(nodeName string, msg []byte) error

SendToNode send message to a node

func (*Membership) SendToOthers

func (m *Membership) SendToOthers(msg []byte)

SendToOthers send message to all nodes except yourself

func (*Membership) Setup

func (m *Membership) Setup() error

func (*Membership) Stat

func (m *Membership) Stat() map[string]int64

func (*Membership) Stop

func (m *Membership) Stop()

type NodeEvents

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

func NewEvents

func NewEvents() *NodeEvents

func (*NodeEvents) NotifyJoin

func (n *NodeEvents) NotifyJoin(node *memberlist.Node)

func (*NodeEvents) NotifyLeave

func (n *NodeEvents) NotifyLeave(node *memberlist.Node)

func (*NodeEvents) NotifyUpdate

func (n *NodeEvents) NotifyUpdate(node *memberlist.Node)

type Option

type Option func(conf *memberlist.Config)

func WithAdvertiseAddr

func WithAdvertiseAddr(advertiseAddr string) Option

WithAdvertiseAddr "" default "0.0.0.0"

func WithAdvertisePort

func WithAdvertisePort(advertisePort int) Option

WithAdvertisePort 0 dynamically bind a port

func WithBindAddr

func WithBindAddr(bindAddr string) Option

WithBindAddr "" default "0.0.0.0"

func WithBindPort

func WithBindPort(bindPort int) Option

WithBindPort 0 dynamically bind a port

func WithCIDRsAllowed

func WithCIDRsAllowed(ips []net.IPNet) Option

func WithDelegate

func WithDelegate(delegate memberlist.Delegate) Option

func WithEvent

func WithEvent(event memberlist.EventDelegate) Option

func WithHandoffQueueDepth

func WithHandoffQueueDepth(depth int) Option

func WithLogOutput

func WithLogOutput(writer io.Writer, level string) Option

func WithNodeName

func WithNodeName(name string) Option

WithNodeName the name of this node. This must be unique in the cluster.

func WithPushPullInterval

func WithPushPullInterval(interval int) Option

func WithSecretKey

func WithSecretKey(secretKey []byte) Option

func WithUDPBufferSize

func WithUDPBufferSize(size int) Option

type RoundRobinBalancer

type RoundRobinBalancer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewRoundRobinBalancer

func NewRoundRobinBalancer(m *Membership) *RoundRobinBalancer

func (*RoundRobinBalancer) Get

Jump to

Keyboard shortcuts

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