cluster

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EVENT_LEADER_DISCOVERY = "LEADER_DISCOVERY"
View Source
const EVENT_LEADER_ECHO = "LEADER_ECHO"
View Source
const EVENT_LEADER_NOMINATE = "LEADER_NOMINATE"
View Source
const EVENT_LEADER_READY = "LEADER_READY"
View Source
const NodeDown string = "NODE_DOWN"
View Source
const NodeLeave string = "NODE_LEAVE"
View Source
const NodeUp string = "NODE_UP"

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(config config.NetworkConfig, req *Request)

send a Broadcast message to network to discovery the cluster

func GetActivePeers

func GetActivePeers() ([]string, map[string]*Node)

func GetLeader

func GetLeader() string

func GetLocalActivePeersCount

func GetLocalActivePeersCount() int

func GetLocalPeers

func GetLocalPeers() map[string]*Node

func GetPeers

func GetPeers() []string

func GetRaftStatus

func GetRaftStatus() string

func GetStats

func GetStats() map[string]string

func InitAPI

func InitAPI()

func Open

func Open() (err error)

func RestoreClusterState

func RestoreClusterState()

RestorePersistID will take the snapshot and restore to id seeds

func ServeMulticastDiscovery

func ServeMulticastDiscovery(config config.NetworkConfig, h func(*net.UDPAddr, int, []byte), signal chan bool)

func SnapshotClusterState

func SnapshotClusterState()

SnapshotPersistID will make a snapshot and persist id stats to disk

Types

type ClusterAPI

type ClusterAPI struct {
	api.Handler
}

type ClusterFSM

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

func NewFSM

func NewFSM() *ClusterFSM

func (*ClusterFSM) Apply

func (f *ClusterFSM) Apply(l *raft.Log) interface{}

Apply applies a Raft log entry to the key-value store.

func (*ClusterFSM) GetClusterMetadata

func (f *ClusterFSM) GetClusterMetadata() Metadata

func (*ClusterFSM) Restore

func (f *ClusterFSM) Restore(rc io.ReadCloser) error

Restore stores the key-value store to a previous state.

func (*ClusterFSM) Snapshot

func (f *ClusterFSM) Snapshot() (raft.FSMSnapshot, error)

Snapshot returns a snapshot of the key-value store.

type Command

type Command struct {
	Op    string `json:"op,omitempty,omitempty"`
	Key   string `json:"key,omitempty,omitempty"`
	Value string `json:"value,omitempty,omitempty"`
}

type Metadata

type Metadata struct {
	KnownNodesRPCEndpoint map[string]*Node `json:"known_nodes"`
}

func GetClusterReadonlyMetadata

func GetClusterReadonlyMetadata() Metadata

type Node

type Node struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`

	ClusterName string `json:"cluster,omitempty"`
	Token       string `json:"token,omitempty"`

	//RaftEndpoint string `json:"raft_endpoint,omitempty"`
	APIEndpoint string `json:"api_endpoint,omitempty"`
	RPCEndpoint string `json:"rpc_endpoint,omitempty"`

	Active bool `json:"active"`

	StartTime int64 `json:"start_time,omitempty"`
	// contains filtered or unexported fields
}

func (*Node) GetRPCAddr

func (v *Node) GetRPCAddr() *net.TCPAddr

type NullWriter

type NullWriter int

func (NullWriter) Write

func (NullWriter) Write([]byte) (int, error)

type RaftModule

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

func New

func New(config *config.ClusterConfig) *RaftModule

func (*RaftModule) Down

func (s *RaftModule) Down(raftAddr, rpcAddr string) error

func (*RaftModule) ExecuteCommand

func (s *RaftModule) ExecuteCommand(c *Command) error

func (*RaftModule) Leave

func (s *RaftModule) Leave(raftAddr, rpcAddr string) error

func (*RaftModule) Up

func (s *RaftModule) Up(node *Node) error

Up joins a node, located at addr, to this store. The node must be ready to respond to Raft communications at that address.

type Request

type Request struct {
	NodeType string `json:"type,omitempty"`
	Node     Node   `json:"node,omitempty"`
	FromNode Node   `json:"local_node,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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