statemachine

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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

type ExampleStateMachine struct {
	ClusterID uint64
	NodeID    uint64
	Count     uint64
}

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.

func (*ExampleStateMachine) Update

func (s *ExampleStateMachine) Update(data []byte) (sm.Result, error)

Update updates the object using the specified committed raft entry.

Jump to

Keyboard shortcuts

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