cluster

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

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

Cluster holds information about the memberlist cluster and active listeners.

func New

func New(bindAddr, advAddr, clusterName, nodeName string, f getClusterInfo) (*Cluster, error)

New configures and creates a new memberlist. To connect the node to the cluster, see (*Cluster).Start.

func (*Cluster) Broadcast

func (c *Cluster) Broadcast(m Message)

func (*Cluster) Close

func (c *Cluster) Close() error

Close gracefully disconnects the node from the memberlist cluster. It tries to wait to broadcast currently pending outgoing messages before leaving.

func (*Cluster) LocalNode

func (c *Cluster) LocalNode() Node

func (*Cluster) Name added in v0.4.0

func (c *Cluster) Name() string

Name returns human-readable cluster name.

func (*Cluster) Nodes

func (c *Cluster) Nodes() []Node

Nodes returns a list of all live nodes in the memberlist.

func (*Cluster) Notify added in v0.2.1

func (c *Cluster) Notify()

func (*Cluster) NotifyJoin

func (c *Cluster) NotifyJoin(node *memberlist.Node)

func (*Cluster) NotifyLeave

func (c *Cluster) NotifyLeave(node *memberlist.Node)

func (*Cluster) NotifyUpdate

func (c *Cluster) NotifyUpdate(node *memberlist.Node)

func (*Cluster) SendTo

func (c *Cluster) SendTo(n Node, m Message) error

func (*Cluster) ShardInfo

func (c *Cluster) ShardInfo(id uint64) dragonboat.ShardView

ShardInfo retrieves a record representing the state of the Raft shard.

func (*Cluster) Start

func (c *Cluster) Start(join []string)

func (*Cluster) WatchKey

func (c *Cluster) WatchKey(key string, f func(message Message))

WatchKey sets up a background listener for the given key. Anytime a message with the key is received, the supplied function f is called.

func (*Cluster) WatchPrefix

func (c *Cluster) WatchPrefix(key string, f func(message Message))

WatchPrefix sets up a background listener for the given key prefix. Anytime a message with a key matching the specified prefix is received, the supplied function f is called.

type Info

type Info struct {
	// NodeHostID is the unique identifier of the NodeHost instance.
	NodeHostID string
	// NodeID is the ID of this replica.
	NodeID uint64
	// RaftAddress is the public address of the NodeHost used for exchanging Raft
	// messages, snapshots and other metadata with other NodeHost instances.
	RaftAddress string
	// ClientAddress is the public address of the Regatta host used for client requests.
	ClientAddress string
	// ShardInfo is a list of all Raft shards managed by the NodeHost
	ShardInfoList []dragonboat.ShardInfo
	// LogInfo is a list of raftio.NodeInfo values representing all Raft logs
	// stored on the NodeHost.
	LogInfo []raftio.NodeInfo
}

Info carries Raft-related information to the particular NodeHost in the cluster.

type Message

type Message struct {
	Key     string `json:"key"`
	Payload []byte `json:"payload"`
}

Message sent between the members of the memberlist.

func (Message) Finished

func (m Message) Finished()

Finished is invoked when the message will no longer be broadcast, either due to invalidation or to the transmit limit being reached.

func (Message) Invalidates

func (m Message) Invalidates(b memberlist.Broadcast) bool

Invalidates checks if enqueuing the current broadcast invalidates a previous broadcast.

func (Message) Message

func (m Message) Message() []byte

Message returns a byte representation of the message.

func (Message) Name

func (m Message) Name() string

Name is a unique identity of this broadcast message.

type Node

type Node struct {
	memberlist.Node
	NodeMeta
}

func (Node) String

func (n Node) String() string

type NodeMeta

type NodeMeta struct {
	ID            string `json:"id"`
	NodeID        uint64 `json:"node_id"`
	ClientAddress string `json:"client_address"`
	RaftAddress   string `json:"raft_address"`
	MemberAddress string `json:"member_address"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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