Documentation ¶
Index ¶
- func NewStateMachine(shardID uint64, replicaID uint64) sm.IStateMachine
- type StateMachine
- func (s *StateMachine) Close() 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(e sm.Entry) (sm.Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStateMachine ¶
func NewStateMachine(shardID uint64, replicaID uint64) sm.IStateMachine
NewStateMachine creates and return a new StateMachine object.
Types ¶
type StateMachine ¶
StateMachine is the IStateMachine implementation used in the example for handling all inputs not ends with "?". See https://github.com/lni/dragonboat/blob/master/statemachine/rsm.go for more details of the IStateMachine interface.
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) 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.