raft

package
v1.9.24 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: MPL-2.0 Imports: 25 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 CommitApplier added in v1.8.0

type CommitApplier func(context.Context, Commit) error

type Config

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

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) AppliedIndex added in v1.8.26

func (rc *RaftNode) AppliedIndex() uint64

func (*RaftNode) Apply

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

func (*RaftNode) CommittedIndex added in v1.8.26

func (rc *RaftNode) CommittedIndex() uint64

func (*RaftNode) GetMembers

func (*RaftNode) GetStatus

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

func (*RaftNode) GetTopology added in v1.9.0

func (*RaftNode) IsLeader

func (rc *RaftNode) IsLeader() bool

func (*RaftNode) IsLearner added in v1.9.0

func (rc *RaftNode) IsLearner() bool

func (*RaftNode) IsRemovedFromCluster

func (rc *RaftNode) IsRemovedFromCluster() bool

func (*RaftNode) IsVoter added in v1.9.0

func (rc *RaftNode) IsVoter() bool

func (*RaftNode) JoinCluster

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

func (*RaftNode) Leader added in v1.9.0

func (rc *RaftNode) Leader() uint64

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) PromoteMember added in v1.9.0

func (rc *RaftNode) PromoteMember(ctx context.Context, in *api.RaftContext) (*api.PromoteMemberResponse, error)

func (*RaftNode) Ready

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

func (*RaftNode) RemoveMember added in v1.8.16

func (rc *RaftNode) RemoveMember(ctx context.Context, message *api.RemoveMemberRequest) (*api.RemoveMemberResponse, 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)

type SnapshotApplier added in v1.8.0

type SnapshotApplier func(context.Context, uint64, *snap.Snapshotter) error

type StableStorage added in v1.8.31

type StableStorage interface {
	io.Closer
	ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb.Entry, err error)
	ReleaseLockTo(index uint64) error
	Save(st raftpb.HardState, ents []raftpb.Entry) error
	Sync() error
	SaveSnapshot(e walpb.Snapshot) error
}

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