Documentation
¶
Index ¶
- func NewStateMachine(clusterID uint64, nodeID uint64) sm.IStateMachine
- type Cluster
- type ClusterConfig
- type NodeConfig
- type StateMachine
- func (s *StateMachine) Close() error
- func (s *StateMachine) GetHash() (uint64, error)
- func (s *StateMachine) Lookup(query interface{}) (interface{}, error)
- func (s *StateMachine) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, done <-chan struct{}) error
- func (s *StateMachine) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, done <-chan struct{}) error
- func (s *StateMachine) Update(data []byte) (sm.Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStateMachine ¶
func NewStateMachine(clusterID uint64, nodeID uint64) sm.IStateMachine
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func NewCluster ¶
func NewCluster(config *ClusterConfig) *Cluster
type ClusterConfig ¶
type ClusterConfig struct {
Nodes []NodeConfig `yaml:"nodes"`
}
type NodeConfig ¶
type StateMachine ¶
StateMachine is the IStateMachine implementation used
func (*StateMachine) Close ¶
func (s *StateMachine) Close() error
Close closes the IStateMachine instance. There is nothing for us to cleanup or release as this is a pure in memory data store. Note that the Close method is not guaranteed to be called as node can crash at any time.
func (*StateMachine) GetHash ¶
func (s *StateMachine) GetHash() (uint64, error)
GetHash returns a uint64 representing the current object state.
func (*StateMachine) Lookup ¶
func (s *StateMachine) Lookup(query interface{}) (interface{}, error)
Lookup performs local lookup on the StateMachine instance. In this example, we always return the Count value as a little endian binary encoded byte slice.
func (*StateMachine) RecoverFromSnapshot ¶
func (s *StateMachine) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, done <-chan struct{}) error
RecoverFromSnapshot recovers the state using the provided snapshot.
func (*StateMachine) SaveSnapshot ¶
func (s *StateMachine) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, done <-chan struct{}) error
SaveSnapshot saves the current IStateMachine state into a snapshot using the specified io.Writer object.