raft

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: MPL-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Ctx     context.Context
	Payload []byte
	ErrCh   chan error
}

type Commit

type Commit struct {
	Index   uint64
	Payload []byte
}

type Config

type Config struct {
	NodeID      uint64
	NodeAddress string
	DataDir     string
	GetSnapshot func() ([]byte, error)
}

type LeaderFunc

type LeaderFunc func(context.Context) error

LeaderFunc is a function that will be run on the Leader node. LeaderFunc must stop as soon as the given context is cancelled.

type Membership

type Membership interface {
	Call(id uint64, f func(*grpc.ClientConn) error) error
	Members() []*clusterpb.Member
}

type NodeConfig

type NodeConfig struct {
	AppliedIndex              uint64
	DisableProposalForwarding bool
	LeaderFunc                LeaderFunc
}

type Peer

type Peer struct {
	ID      uint64
	Address string
}

Peer represents a remote raft peer

func (Peer) MarshalLogObject

func (p Peer) MarshalLogObject(e zapcore.ObjectEncoder) error

type Peers

type Peers []Peer

func (Peers) MarshalLogArray

func (p Peers) MarshalLogArray(e zapcore.ArrayEncoder) error

type RaftNode

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

func NewNode

func NewNode(config Config, mesh Membership, logger *zap.Logger) *RaftNode

NewNode initiates a raft instance and returns a committed log entry channel and error channel. Proposals for log updates are sent over the provided the proposal channel. All log entries are replayed over the commit channel, followed by a nil message (to indicate the channel is current), then new log entries. To shutdown, close proposeC and read errorC.

func (*RaftNode) Apply

func (rc *RaftNode) Apply(ctx context.Context, buf []byte) error

stop closes http, closes all channels, and stops raft.

func (*RaftNode) Commits

func (rc *RaftNode) Commits() <-chan Commit

func (*RaftNode) GetMembers

func (*RaftNode) GetStatus

func (rc *RaftNode) GetStatus(ctx context.Context, in *api.GetStatusRequest) (*api.GetStatusResponse, error)

func (*RaftNode) IsLeader

func (rc *RaftNode) IsLeader() bool

func (*RaftNode) IsRemovedFromCluster

func (rc *RaftNode) IsRemovedFromCluster() bool

func (*RaftNode) JoinCluster

func (rc *RaftNode) JoinCluster(ctx context.Context, in *api.RaftContext) (*api.JoinClusterResponse, error)

func (*RaftNode) Leave

func (rc *RaftNode) Leave(ctx context.Context) error

func (*RaftNode) Process

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

func (*RaftNode) ProcessMessage

func (rc *RaftNode) ProcessMessage(ctx context.Context, message *raftpb.Message) (*api.Payload, error)

func (*RaftNode) Ready

func (rc *RaftNode) Ready() <-chan struct{}

func (*RaftNode) ReportNewPeer

func (rc *RaftNode) ReportNewPeer(ctx context.Context, id uint64, address string) error

func (*RaftNode) ReportSnapshot

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

func (*RaftNode) ReportUnreachable

func (rc *RaftNode) ReportUnreachable(id uint64)

func (*RaftNode) Run

func (rc *RaftNode) Run(ctx context.Context, peers []Peer, join bool, config NodeConfig)

func (*RaftNode) Send

func (rc *RaftNode) Send(ctx context.Context, messages []raftpb.Message)

func (*RaftNode) Serve

func (rc *RaftNode) Serve(grpcServer *grpc.Server)

func (*RaftNode) Snapshotter

func (rc *RaftNode) Snapshotter() <-chan *snap.Snapshotter

type StatsProvider

type StatsProvider interface {
	Histogram(name string) *prometheus.Histogram
}

type StatsProviderGetter

type StatsProviderGetter func() StatsProvider

Jump to

Keyboard shortcuts

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