fsm

package
v0.0.0-...-c46e59b Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFSM

func NewFSM(handlers ...CMDHandlerFunc) raft.FSM

Types

type CMD

type CMD struct {
	Method     Method `json:"method"`
	Node       model.Node
	Relation   model.Relation
	AddNodes   []*model.AddNode
	SetNodes   []*model.SetNode
	Key        model.Key
	Keys       []*model.Key
	Properties map[string]interface{}
	Timestamp  time.Time         `json:"timestamp"`
	Metadata   map[string]string `json:"metadata"`
}

type CMDHandlerFunc

type CMDHandlerFunc func(c CMD) ([]interface{}, error)

type FSM

type FSM struct {
	ApplyFunc    func(log *raft.Log) interface{}
	SnapshotFunc func() (*Snapshot, error)
	RestoreFunc  func(closer io.ReadCloser) error
}

func (*FSM) Apply

func (f *FSM) Apply(log *raft.Log) interface{}

func (*FSM) Restore

func (f *FSM) Restore(closer io.ReadCloser) error

func (*FSM) Snapshot

func (f *FSM) Snapshot() (raft.FSMSnapshot, error)

type Method

type Method string
const (
	MethodRelationSetProperties Method = "relation.set_properties"

	MethodSet               Method = "set"
	MethodAdd               Method = "add"
	MethodDel               Method = "del"
	MethodNodeDelRelation   Method = "node.del_relation"
	MethodNodeAddRelation   Method = "node.add_relation"
	MethodNodeSetProperties Method = "node.set_properties"
	MethodBulkAdd           Method = "bulk_add"
	MethodBulkSet           Method = "bulk_set"
	MethodBulkDel           Method = "bulk_del"
)

type Snapshot

type Snapshot struct {
	PersistFunc func(sink raft.SnapshotSink) error
	ReleaseFunc func()
}

func (*Snapshot) Persist

func (s *Snapshot) Persist(sink raft.SnapshotSink) error

func (*Snapshot) Release

func (s *Snapshot) Release()

Jump to

Keyboard shortcuts

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