cluster

package
v0.0.0-...-ab4a820 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

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)

var lastBroadcast time.Time 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 GetNodes

func GetNodes() []string

get all nodes, include self

func GetPeers

func GetPeers() []string

other peers, self not include

func GetRaftStatus

func GetRaftStatus() string

func GetStats

func GetStats() map[string]string

func InitAPI

func InitAPI()

func Open

func Open() (err error)

func RefreshAllKnowPeers

func RefreshAllKnowPeers()

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 RESTART_TYPE

type RESTART_TYPE string
const RESTART_WITH_INITIAL_STATE RESTART_TYPE = "RESTART_WITH_INITIAL_STATE"
const RESTART_WITH_KNOWN_LEADER RESTART_TYPE = "RESTART_WITH_KNOWN_LEADER"
const RESTART_WITH_LEADER_SELECTION RESTART_TYPE = "RESTART_WITH_LEADER_SELECTION"
const RESTART_WITH_SELFT_PROMOTE RESTART_TYPE = "RESTART_WITH_SELFT_PROMOTE"

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:"from,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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