raft

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend ...

func New

func New(
	db dbApi.Backend,
	config *Config) (*Backend, error)

New ...

func (*Backend) AppliedIndex

func (d *Backend) AppliedIndex() uint64

AppliedIndex returns the latest index applied to the FSM

func (*Backend) ApplyFuncRead added in v0.4.7

func (d *Backend) ApplyFuncRead(
	roLevel rkvApi.ConsistencyLevel,
	name string, args ...[]byte) (interface{}, error)

ApplyFuncRead calls 'name' function on raft cluster

func (*Backend) ApplyFuncWrite added in v0.4.7

func (d *Backend) ApplyFuncWrite(
	name string, args ...[]byte) (interface{}, error)

ApplyFuncWrite calls 'name' function on raft cluster

func (*Backend) Batch added in v0.1.2

func (d *Backend) Batch(commands []*dbApi.BatchEntry) (interface{}, error)

Batch apply multiple put, delete operations

func (*Backend) Close

func (d *Backend) Close() error

Close ...

func (*Backend) CommittedIndex

func (d *Backend) CommittedIndex() uint64

CommittedIndex returns the latest index committed to stable storage

func (*Backend) Delete

func (d *Backend) Delete(tab, key []byte) error

Delete inserts an entry in the log to delete the given key

func (*Backend) Get

func (d *Backend) Get(
	lvl rkvApi.ConsistencyLevel, tab, key []byte) ([]byte, error)

Get returns value from local backend

func (*Backend) IsLeader

func (d *Backend) IsLeader() bool

IsLeader returns if raft is leader

func (*Backend) Join

func (d *Backend) Join(id string, tags map[string]string, local bool) error

Join ... func (d *Backend) Join(id, raftAddr, rpcAddr string, local bool) error {

func (*Backend) Leader added in v0.3.2

func (d *Backend) Leader() (string, string)

Leader returns raft leader address

func (*Backend) Leave

func (d *Backend) Leave(id string, tags map[string]string, local bool) error

Leave ... func (d *Backend) Leave(id, raftAddr string, local bool) error {

func (*Backend) Put

func (d *Backend) Put(tab, key, val []byte) error

Put apply value via raft

func (*Backend) RaftAddr added in v0.1.3

func (d *Backend) RaftAddr() net.Addr

RaftAddr returns raft transport address

func (*Backend) Restarted

func (d *Backend) Restarted() bool

Restarted check node has state

func (*Backend) Servers

func (d *Backend) Servers() ([]*clusterApi.Server, error)

Servers returns cluster servers

func (*Backend) WaitForLeader

func (d *Backend) WaitForLeader(timeout time.Duration) error

WaitForLeader ...

type Config

type Config struct {
	Raft             raft.Config
	RPCAddr          string
	RaftAddr         string // hostname for bootstrap by name, not ip
	StreamLayer      *StreamLayer
	Bootstrap        bool
	ApplyRegistrator rkvApi.ApplyRegistrator
	OnLeaderChangeFn func(isLeader bool)
}

Config for distributed Db

func (Config) ServerID

func (c Config) ServerID(id string) raft.ServerID

ServerID returns raft.ServerID from string

type StreamLayer

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

StreamLayer is the network service provided to Raft

func NewStreamLayer

func NewStreamLayer(ln net.Listener) *StreamLayer

NewStreamLayer ...

func (*StreamLayer) Accept

func (t *StreamLayer) Accept() (net.Conn, error)

Accept waits for the next connection.

func (*StreamLayer) Addr

func (t *StreamLayer) Addr() net.Addr

Addr returns the binding address of the StreamLayer.

func (*StreamLayer) Close

func (t *StreamLayer) Close() error

Close closes the StreamLayer

func (*StreamLayer) Dial

func (t *StreamLayer) Dial(
	addr raft.ServerAddress,
	timeout time.Duration) (net.Conn, error)

Dial creates a new network connection.

Jump to

Keyboard shortcuts

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