raft

package
v0.0.2-0...-6735cf7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProcessFnAlreadyRegisteredErr  error = errors.New("ProcessFn already registered")
	SnapshotFnAlreadyRegisteredErr error = errors.New("SnapshotFn already registered")
)
View Source
var (
	GroupAlreadyExistsError error = errors.New("Group already exists")
	GroupNotFoundError      error = errors.New("Group not found")
)

Functions

func NewSharedGroup

func NewSharedGroup(group *RaftGroup) (*sharedGroup, error)

Types

type Group

type Group interface {
	RegisterProcessFn(ProcessFn) error
	RegisterProcessSnapshotFn(ProcessFn) error
	RegisterSnapshotFn(SnapshotFn) error
	LeaderId() uint64
	Propose(context.Context, []byte) error
}

type NodesManager

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

func NewNodesManager

func NewNodesManager(clusterConn *cluster.Conn, zeroGroup *RaftGroup) *NodesManager

func (*NodesManager) AddNode

func (this *NodesManager) AddNode(id uint64, address string) (map[uint64]string, error)

func (*NodesManager) Join

func (this *NodesManager) Join(ctx context.Context, addresses []string) error

func (*NodesManager) ListNodes

func (this *NodesManager) ListNodes() map[uint64]string

func (*NodesManager) RemoveNode

func (this *NodesManager) RemoveNode(id uint64) error

type ProcessFn

type ProcessFn func([]byte) error

type RaftGroup

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

func NewRaftGroup

func NewRaftGroup(id uuid.UUID, nodeIds []uint64, storage wal.WAL, transport *RaftTransport) (*RaftGroup, error)

func (*RaftGroup) LeaderId

func (this *RaftGroup) LeaderId() uint64

func (*RaftGroup) Propose

func (this *RaftGroup) Propose(ctx context.Context, data []byte) error

func (*RaftGroup) ProposeJoin

func (this *RaftGroup) ProposeJoin(nodeId uint64, address string) error

func (*RaftGroup) ProposeLeave

func (this *RaftGroup) ProposeLeave(nodeId uint64) error

func (*RaftGroup) RegisterProcessFn

func (this *RaftGroup) RegisterProcessFn(fn ProcessFn) error

func (*RaftGroup) RegisterProcessSnapshotFn

func (this *RaftGroup) RegisterProcessSnapshotFn(fn ProcessFn) error

func (*RaftGroup) RegisterSnapshotFn

func (this *RaftGroup) RegisterSnapshotFn(fn SnapshotFn) error

func (*RaftGroup) Start

func (this *RaftGroup) Start() error

func (*RaftGroup) Stop

func (this *RaftGroup) Stop()

type RaftTransport

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

func NewTransport

func NewTransport(nodeId uint64, address string, clusterConn *cluster.Conn) *RaftTransport

func (*RaftTransport) Address

func (this *RaftTransport) Address() string

func (*RaftTransport) NodeId

func (this *RaftTransport) NodeId() uint64

func (*RaftTransport) Receive

func (this *RaftTransport) Receive(ctx context.Context, req *pb.RaftMessage) (*pb.EmptyMessage, error)

func (*RaftTransport) Send

func (this *RaftTransport) Send(ctx context.Context, group *RaftGroup, messages []raftpb.Message)

type SnapshotFn

type SnapshotFn func() ([]byte, error)

Jump to

Keyboard shortcuts

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