Documentation ¶
Index ¶
- Constants
- func Broadcast(config config.NetworkConfig, req *Request)
- func GetActivePeers() ([]string, map[string]*Node)
- func GetLeader() string
- func GetLocalActivePeersCount() int
- func GetLocalPeers() map[string]*Node
- func GetPeers() []string
- func GetRaftStatus() string
- func GetStats() map[string]string
- func InitAPI()
- func Open() (err error)
- func RestoreClusterState()
- func ServeMulticastDiscovery(config config.NetworkConfig, h func(*net.UDPAddr, int, []byte), ...)
- func SnapshotClusterState()
- type ClusterAPI
- type ClusterFSM
- type Command
- type Metadata
- type Node
- type NullWriter
- type RaftModule
- type Request
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 GetLocalActivePeersCount ¶
func GetLocalActivePeersCount() int
func GetLocalPeers ¶
func GetRaftStatus ¶
func GetRaftStatus() string
func RestoreClusterState ¶
func RestoreClusterState()
RestorePersistID will take the snapshot and restore to id seeds
func ServeMulticastDiscovery ¶
func SnapshotClusterState ¶
func SnapshotClusterState()
SnapshotPersistID will make a snapshot and persist id stats to disk
Types ¶
type ClusterAPI ¶
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 Metadata ¶
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 ¶
type NullWriter ¶
type NullWriter int
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.
Click to show internal directories.
Click to hide internal directories.