raft

package module
v0.0.0-...-b71a817 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: MIT Imports: 19 Imported by: 0

README

raft-wrapper

Wrap github.com/coreos/etcd/raft for simpler usage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyStore

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

func (*DummyStore) Commit

func (s *DummyStore) Commit(data []byte) error

func (*DummyStore) GetSnapshot

func (s *DummyStore) GetSnapshot() ([]byte, error)

func (*DummyStore) LoadSnapshot

func (s *DummyStore) LoadSnapshot(data []byte) error

type HTTPTransport

type HTTPTransport struct {
	rafthttp.Transport
	// contains filtered or unexported fields
}

func (*HTTPTransport) ChangeConf

func (t *HTTPTransport) ChangeConf(cc raftpb.ConfChange) error

func (*HTTPTransport) ErrorC

func (t *HTTPTransport) ErrorC() <-chan error

func (*HTTPTransport) Start

func (t *HTTPTransport) Start() error

func (*HTTPTransport) Stop

func (t *HTTPTransport) Stop() error

type MemStorage

type MemStorage struct {
	raft.MemoryStorage
	// contains filtered or unexported fields
}

func NewMemStorage

func NewMemStorage(walDir, snapDir string) (*MemStorage, error)

func (*MemStorage) IsEmpty

func (s *MemStorage) IsEmpty() bool

func (*MemStorage) Save

func (s *MemStorage) Save(rd raft.Ready) error

type RaftNode

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

func NewRaftNode

func NewRaftNode(opts ...RaftOption) (*RaftNode, error)

func (*RaftNode) IsIDRemoved

func (r *RaftNode) IsIDRemoved(id uint64) bool

func (*RaftNode) Process

func (r *RaftNode) Process(ctx context.Context, m raftpb.Message) error

func (*RaftNode) Propose

func (r *RaftNode) Propose(data []byte) error

func (*RaftNode) ProposeConfChange

func (r *RaftNode) ProposeConfChange(cc raftpb.ConfChange) error

func (*RaftNode) ReportSnapshot

func (r *RaftNode) ReportSnapshot(id uint64, status raft.SnapshotStatus)

func (*RaftNode) ReportUnreachable

func (r *RaftNode) ReportUnreachable(id uint64)

func (*RaftNode) Start

func (r *RaftNode) Start() error

func (*RaftNode) Stop

func (r *RaftNode) Stop() error

type RaftOption

type RaftOption func(r *RaftNode) error

func WithCommitFunc

func WithCommitFunc(commitFunc func([]byte) error) RaftOption

func WithID

func WithID(id int) RaftOption

func WithPeers

func WithPeers(peers ...string) RaftOption

func WithStorage

func WithStorage(m Storage) RaftOption

func WithTransport

func WithTransport(t func(r *RaftNode) (Transport, error)) RaftOption

type Storage

type Storage interface {
	raft.Storage
	IsEmpty() bool
	Save(rd raft.Ready) error
}

type Transport

type Transport interface {
	Send(messages []raftpb.Message)
	Start() error
	Stop() error
	ChangeConf(cc raftpb.ConfChange) error
	ErrorC() <-chan error
}

func NewHTTPTransport

func NewHTTPTransport(r *RaftNode) (Transport, error)

Jump to

Keyboard shortcuts

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