Documentation
¶
Index ¶
- func NewExampleStateMachine(clusterID uint64, nodeID uint64) sm.IStateMachine
- type ExampleStateMachine
- func (s *ExampleStateMachine) Close() error
- func (s *ExampleStateMachine) Lookup(query interface{}) (interface{}, error)
- func (s *ExampleStateMachine) RecoverFromSnapshot(r io.Reader, _ []sm.SnapshotFile, _ <-chan struct{}) error
- func (s *ExampleStateMachine) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, _ <-chan struct{}) error
- func (s *ExampleStateMachine) Update(data []byte) (sm.Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewExampleStateMachine ¶
func NewExampleStateMachine(clusterID uint64, nodeID uint64) sm.IStateMachine
NewExampleStateMachine creates and return a new ExampleStateMachine object.
Types ¶
type ExampleStateMachine ¶
ExampleStateMachine is the IStateMachine implementation used in the hello world example. See https://github.com/lni/dragonboat/blob/master/statemachine/rsm.go for more details of the IStateMachine interface.
func (*ExampleStateMachine) Close ¶
func (s *ExampleStateMachine) Close() error
Close closes the IStateMachine instance. There is nothing for us to clean up 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 (*ExampleStateMachine) Lookup ¶
func (s *ExampleStateMachine) Lookup(query interface{}) (interface{}, error)
Lookup performs local lookup on the ExampleStateMachine instance. In this example, we always return the Count value as a little endian binary encoded byte slice.
func (*ExampleStateMachine) RecoverFromSnapshot ¶
func (s *ExampleStateMachine) RecoverFromSnapshot(r io.Reader, _ []sm.SnapshotFile, _ <-chan struct{}) error
RecoverFromSnapshot recovers the state using the provided snapshot.
func (*ExampleStateMachine) SaveSnapshot ¶
func (s *ExampleStateMachine) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, _ <-chan struct{}) error
SaveSnapshot saves the current IStateMachine state into a snapshot using the specified io.Writer object.