node

package
v0.0.0-...-09171fd Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: EPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStateMachine

func NewStateMachine(clusterID uint64, nodeID uint64) sm.IStateMachine

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(config *ClusterConfig) *Cluster

func (*Cluster) Start

func (c *Cluster) Start(nodeAddr string)

type ClusterConfig

type ClusterConfig struct {
	Nodes []NodeConfig `yaml:"nodes"`
}

type NodeConfig

type NodeConfig struct {
	Name string `yaml:"name"`
	Addr string `yaml:"addr"`
}

type StateMachine

type StateMachine struct {
	ClusterID uint64
	NodeID    uint64
	VM        *yar.VM
}

StateMachine is the IStateMachine implementation used

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) GetHash

func (s *StateMachine) GetHash() (uint64, error)

GetHash returns a uint64 representing the current object state.

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.

func (*StateMachine) Update

func (s *StateMachine) 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