raft

package
v0.0.0-...-20020d3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Op  string
	Key []byte
	Val []byte
}

type Kv

type Kv struct {
	Dir   string
	Id    string
	Addr  string
	Peers map[string]string
	Raft  *raft.Raft
	Db    *db.Kv
}

func NewKv

func NewKv(dir string, id string, addr string, peers map[string]string) (*Kv, error)

func (*Kv) Apply

func (k *Kv) Apply(log *raft.Log) interface{}

Apply log is invoked once a log enetry is committed.

func (*Kv) Close

func (k *Kv) Close()

func (*Kv) Delete

func (k *Kv) Delete(key []byte) error

func (*Kv) Get

func (k *Kv) Get(key []byte) ([]byte, error)

func (*Kv) GetLeader

func (k *Kv) GetLeader() (bool, string)

func (*Kv) Join

func (k *Kv) Join(nodeId string, nodeAddr string) error

func (*Kv) Restore

func (k *Kv) Restore(rc io.ReadCloser) error

Restore is used to restore an FSM from a snapshot.

func (*Kv) Set

func (k *Kv) Set(key []byte, val []byte) error

func (*Kv) Snapshot

func (k *Kv) 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.

Jump to

Keyboard shortcuts

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