tdragonboat

package
v0.0.0-...-1f4ee57 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

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

type ExampleStateMachine struct {
	ClusterID uint64
	NodeID    uint64
	Count     uint64
}

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

type SecondStateMachine struct {
	ClusterID uint64
	NodeID    uint64
	Count     uint64
}

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 NewStopper

func NewStopper() *Stopper

NewStopper return a new Stopper instance.

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.

func (*Stopper) Stop

func (s *Stopper) Stop()

Stop signals all managed worker goroutines to stop and wait for them to actually stop.

func (*Stopper) Wait

func (s *Stopper) Wait()

Wait waits on the internal sync.WaitGroup. It only return when all managed worker goroutines are ready to return and called sync.WaitGroup.Done() on the internal sync.WaitGroup.

Jump to

Keyboard shortcuts

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