fsm

package
v0.0.0-...-8253ce3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResponse

type ApplyResponse struct {
	Error error
	Data  interface{}
}

ApplyResponse response from Apply raft

type ArimaFSM

type ArimaFSM struct {
	Conn *badger.DB
}

func NewArimaFSM

func NewArimaFSM(path string) (*ArimaFSM, error)

func (*ArimaFSM) Apply

func (fsm *ArimaFSM) Apply(log *raft.Log) interface{}

Apply log is invoked once a log entry is committed. It returns a value which will be made available in the ApplyFuture returned by Raft.Apply method if that method was called on the same Raft node as the FSM.

func (*ArimaFSM) Get

func (fsm *ArimaFSM) Get(key []byte) ([]byte, error)

func (*ArimaFSM) Restore

func (fsm *ArimaFSM) Restore(r io.ReadCloser) error

Restore is used to restore an FSM from a snapshot. It is not called concurrently with any other command. The FSM must discard all previous state.

func (*ArimaFSM) Snapshot

func (fsm *ArimaFSM) Snapshot() (raft.FSMSnapshot, error)

Snapshot is used to support log compaction. This call should return an FSMSnapshot which can be used to save a point-in-time snapshot of the FSM.

type ArimaSnapshot

type ArimaSnapshot struct {
	Conn *badger.DB
}

func (*ArimaSnapshot) Persist

func (snap *ArimaSnapshot) Persist(sink raft.SnapshotSink) error

Persist should dump all necessary state to the WriteCloser 'sink', and call sink.Close() when finished or call sink.Cancel() on error.

func (*ArimaSnapshot) Release

func (snap *ArimaSnapshot) Release()

Release is invoked when we are finished with the snapshot.

type CommandPayload

type CommandPayload struct {
	Operation string
	Key       []byte
	Value     []byte
}

CommandPayload is payload sent by system when calling raft.Apply(cmd []byte, timeout time.Duration)

Jump to

Keyboard shortcuts

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