fsm

package
v0.0.0-...-a01d039 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNumericalID

func GetNumericalID(ID string, peers []string) int

GetNumericalID is used to get the numerical ID of a node from the list of peers parameters: ID (a string identifier of the node), peers (an array of current nodes in the cluster) returns: int (the numeric value of a node's indentifier), otherwise -1

func PeersList

func PeersList(rawConfig string) []string

PeersList is used to get the list of peers from a raft config parameters: rawConfig (latest_configuration section of the raft stats) returns: []string (a string array of all nodes in the cluster)

Types

type Store

type Store struct {
	RaftDir     string
	RaftBind    string
	Raft        *raft.Raft
	ServerID    string
	NumericalID int
	PeersLength int
}

Store is a type which contains node and raft information

func NewStore

func NewStore() *Store

NewStore is used to initialize a Store tstruct parameters: nil returns: *Store (a pointer to a newly initialized store)

func (*Store) Join

func (s *Store) Join(nodeID, addr string) error

Join is called on a store type and is used to join a node to the cluster parameters: nodeID (a string used to represent a node by name), addr (a string used to denote the address to be used by the server) returns: error if an error occurs during this bootstrapping process, otherwise nil

func (*Store) Leave

func (s *Store) Leave(nodeID string) error

Leave is called on a store type and is used to remove a node from the cluster parameters: nodeID (a string used to represent a node by name) returns: error if an error occurs during this bootstrapping process, otherwise nil

func (*Store) Open

func (s *Store) Open(enableSingle bool, localID string) error

Open is called on a store type and is used to boostrap the cluster parameters: enableSingle (a boolean used to allow single node cluster setup), localID (a string used to define the ID of a server) returns: error if an error occurs during this bootstrapping process, otherwise nil

Jump to

Keyboard shortcuts

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