Documentation
¶
Index ¶
- func Dragonboat()
- func NewExampleStateMachine(clusterID uint64, nodeID uint64) statemachine.IStateMachine
- func NewSecondStateMachine(clusterID uint64, nodeID uint64) statemachine.IStateMachine
- type ExampleStateMachine
- func (s *ExampleStateMachine) Close()
- func (s *ExampleStateMachine) GetHash() uint64
- func (s *ExampleStateMachine) Lookup(query []byte) []byte
- func (s *ExampleStateMachine) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error
- func (s *ExampleStateMachine) SaveSnapshot(w io.Writer, fc statemachine.ISnapshotFileCollection, done <-chan struct{}) (uint64, error)
- func (s *ExampleStateMachine) Update(data []byte) uint64
- type SecondStateMachine
- func (s *SecondStateMachine) Close()
- func (s *SecondStateMachine) GetHash() uint64
- func (s *SecondStateMachine) Lookup(query []byte) []byte
- func (s *SecondStateMachine) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error
- func (s *SecondStateMachine) SaveSnapshot(w io.Writer, fc statemachine.ISnapshotFileCollection, done <-chan struct{}) (uint64, error)
- func (s *SecondStateMachine) Update(data []byte) uint64
- type Stopper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dragonboat ¶
func Dragonboat()
func NewExampleStateMachine ¶
func NewExampleStateMachine(clusterID uint64, nodeID uint64) statemachine.IStateMachine
NewExampleStateMachine creates and return a new ExampleStateMachine object.
func NewSecondStateMachine ¶
func NewSecondStateMachine(clusterID uint64, nodeID uint64) statemachine.IStateMachine
NewSecondStateMachine creates and return a new SecondStateMachine object.
Types ¶
type ExampleStateMachine ¶
func (*ExampleStateMachine) Close ¶
func (s *ExampleStateMachine) Close()
CloseDao 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 CloseDao method is not guaranteed to be called as node can crash at any time.
func (*ExampleStateMachine) GetHash ¶
func (s *ExampleStateMachine) GetHash() uint64
GetHash returns a uint64 representing the current object state.
func (*ExampleStateMachine) Lookup ¶
func (s *ExampleStateMachine) Lookup(query []byte) []byte
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, files []statemachine.SnapshotFile, done <-chan struct{}) error
RecoverFromSnapshot recovers the state using the provided snapshot.
func (*ExampleStateMachine) SaveSnapshot ¶
func (s *ExampleStateMachine) SaveSnapshot(w io.Writer, fc statemachine.ISnapshotFileCollection, done <-chan struct{}) (uint64, error)
SaveSnapshot saves the current IStateMachine state into a snapshot using the specified io.Writer object.
func (*ExampleStateMachine) Update ¶
func (s *ExampleStateMachine) Update(data []byte) uint64
Update updates the object using the specified committed raft entry.
type SecondStateMachine ¶
SecondStateMachine is the IStateMachine implementation used in the multigroup example for handling all inputs ends with "?". See https://github.com/lni/dragonboat/blob/master/statemachine/rsm.go for more details of the IStateMachine interface. The behaviour of SecondStateMachine is similar to the ExampleStateMachine. The biggest difference is that its Update() method has different print out messages. See Update() for details.
func (*SecondStateMachine) Close ¶
func (s *SecondStateMachine) Close()
CloseDao 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 CloseDao method is not guaranteed to be called as node can crash at any time.
func (*SecondStateMachine) GetHash ¶
func (s *SecondStateMachine) GetHash() uint64
GetHash returns a uint64 representing the current object state.
func (*SecondStateMachine) Lookup ¶
func (s *SecondStateMachine) Lookup(query []byte) []byte
Lookup performs local lookup on the SecondStateMachine instance. In this example, we always return the Count value as a little endian binary encoded byte slice.
func (*SecondStateMachine) RecoverFromSnapshot ¶
func (s *SecondStateMachine) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error
RecoverFromSnapshot recovers the state using the provided snapshot.
func (*SecondStateMachine) SaveSnapshot ¶
func (s *SecondStateMachine) SaveSnapshot(w io.Writer, fc statemachine.ISnapshotFileCollection, done <-chan struct{}) (uint64, error)
SaveSnapshot saves the current IStateMachine state into a snapshot using the specified io.Writer object.
func (*SecondStateMachine) Update ¶
func (s *SecondStateMachine) Update(data []byte) uint64
Update updates the object using the specified committed raft entry.
type Stopper ¶
type Stopper struct {
// contains filtered or unexported fields
}
Stopper is a manager struct for managing worker goroutines.
func (*Stopper) Close ¶
func (s *Stopper) Close()
CloseDao closes the internal shouldStopc chan struct{} to signal all worker goroutines that they should stop.
func (*Stopper) RunWorker ¶
func (s *Stopper) RunWorker(f func())
RunWorker creates a new goroutine and invoke the f func in that new worker goroutine.
func (*Stopper) ShouldStop ¶
func (s *Stopper) ShouldStop() chan struct{}
ShouldStop returns a chan struct{} used for indicating whether the Stop() function has been called on Stopper.