Documentation ¶
Index ¶
- Constants
- type AEQueue
- type Config
- type Raft
- func (r *Raft) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
- func (r *Raft) CatchMeUp(ctx context.Context, req *pb.CatchMeUpRequest) (res *pb.Empty, err error)
- func (r *Raft) HandleAppendEntriesRequest(req *pb.AppendEntriesRequest) *pb.AppendEntriesResponse
- func (r *Raft) HandleAppendEntriesResponse(response *pb.AppendEntriesQFResponse, maxIndex uint64)
- func (r *Raft) HandleInstallSnapshotRequest(snapshot *commonpb.Snapshot) (res *pb.InstallSnapshotResponse)
- func (r *Raft) HandleInstallSnapshotResponse(res *pb.InstallSnapshotResponse) bool
- func (r *Raft) HandleRequestVoteRequest(req *pb.RequestVoteRequest) *pb.RequestVoteResponse
- func (r *Raft) HandleRequestVoteResponse(response *pb.RequestVoteResponse)
- func (r *Raft) InstallSnapshot(ctx context.Context, snapshot *commonpb.Snapshot) (*pb.InstallSnapshotResponse, error)
- func (r *Raft) ProposeCmd(ctx context.Context, cmd []byte) (raft.Future, error)
- func (r *Raft) ProposeConf(ctx context.Context, req *commonpb.ReconfRequest) (raft.Future, error)
- func (r *Raft) ReadCmd(ctx context.Context, cmd []byte) (raft.Future, error)
- func (r *Raft) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
- func (r *Raft) Run(server *grpc.Server, opts ...gorums.ManagerOption) error
- func (r *Raft) State() State
- func (r *Raft) Stop()
- type RaftQuorumSpec
- type State
Constants ¶
const BufferSize = 10000
BufferSize is the initial buffer size used for maps and buffered channels that directly depend on the number of requests being serviced.
const None = 0
None represents no server.
const TCPConnect = 50000
TCPConnect specifies how long the manager will attempt to establish a connection to all servers.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AEQueue ¶
type AEQueue []*pb.AppendEntriesRequest
AEQueue implements the heap interface
func InitAEQueue ¶
type Config ¶
type Config struct { ID uint64 Servers []string // IDs of server which forms the initial cluster. IDs start at 1, which // refers to the first server in Servers. InitialCluster []uint64 Storage raft.Storage Batch bool ElectionTimeout time.Duration HeartbeatTimeout time.Duration EntriesPerMsg uint64 // CatchupMultiplier is how many times more EntriesPerMsg we are allowed // to use when doing a catch up, i.e., EntriesPerMsg*CatchupMultiplier. CatchupMultiplier uint64 // Catchup will be sent if this many committed entries are missing from the log MaxMissingCommit uint64 // Maximum number of out of order append entry requests buffered, before sending catchup MaxAEBuffer uint64 Logger logrus.FieldLogger CheckQuorum bool MetricsEnabled bool }
Config contains the configuration needed to start an instance of Raft.
type Raft ¶
type Raft struct {
// contains filtered or unexported fields
}
Raft represents an instance of the Raft algorithm.
func NewRaft ¶
func NewRaft(sm raft.StateMachine, cfg *Config, lat *raft.Latency, event *raft.Event, leaderOut chan struct{}) *Raft
NewRaft returns a new Raft given a configuration.
func (*Raft) AppendEntries ¶
func (r *Raft) AppendEntries(ctx context.Context, req *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
AppendEntries implements gorums.RaftServer.
func (*Raft) HandleAppendEntriesRequest ¶
func (r *Raft) HandleAppendEntriesRequest(req *pb.AppendEntriesRequest) *pb.AppendEntriesResponse
HandleAppendEntriesRequest must be called when receiving a AppendEntriesRequest, the return value must be delivered to the requester.
func (*Raft) HandleAppendEntriesResponse ¶
func (r *Raft) HandleAppendEntriesResponse(response *pb.AppendEntriesQFResponse, maxIndex uint64)
HandleAppendEntriesResponse must be invoked when receiving an AppendEntriesResponse.
func (*Raft) HandleInstallSnapshotRequest ¶
func (r *Raft) HandleInstallSnapshotRequest(snapshot *commonpb.Snapshot) (res *pb.InstallSnapshotResponse)
func (*Raft) HandleInstallSnapshotResponse ¶
func (r *Raft) HandleInstallSnapshotResponse(res *pb.InstallSnapshotResponse) bool
func (*Raft) HandleRequestVoteRequest ¶
func (r *Raft) HandleRequestVoteRequest(req *pb.RequestVoteRequest) *pb.RequestVoteResponse
HandleRequestVoteRequest must be called when receiving a RequestVoteRequest, the return value must be delivered to the requester.
func (*Raft) HandleRequestVoteResponse ¶
func (r *Raft) HandleRequestVoteResponse(response *pb.RequestVoteResponse)
HandleRequestVoteResponse must be invoked when receiving a RequestVoteResponse.
func (*Raft) InstallSnapshot ¶
func (r *Raft) InstallSnapshot(ctx context.Context, snapshot *commonpb.Snapshot) (*pb.InstallSnapshotResponse, error)
InstallSnapshot implements gorums.RaftServer.
func (*Raft) ProposeCmd ¶
ProposeCmd implements raft.Raft.
func (*Raft) ProposeConf ¶
ProposeConf implements raft.Raft.
func (*Raft) RequestVote ¶
func (r *Raft) RequestVote(ctx context.Context, req *pb.RequestVoteRequest) (*pb.RequestVoteResponse, error)
RequestVote implements gorums.RaftServer.
type RaftQuorumSpec ¶
RaftQuorumSpec holds information about the quorum size of the current configuration and allows us to invoke quorum calls.
func NewQuorumSpec ¶
func NewQuorumSpec(peers int) *RaftQuorumSpec
NewQuorumSpec returns a RaftQuorumSpec for len(peers). You need to add 1 if you don't include yourself.
func (*RaftQuorumSpec) AppendEntriesQF ¶
func (qs *RaftQuorumSpec) AppendEntriesQF(req *pb.AppendEntriesRequest, replies []*pb.AppendEntriesResponse) (*pb.AppendEntriesQFResponse, bool)
AppendEntriesQF gathers AppendEntriesResponses and calculates the log entries replicated, depending on the quorum configuration. TODO Implements gorums.QuorumSpec interface.
func (*RaftQuorumSpec) RequestVoteQF ¶
func (qs *RaftQuorumSpec) RequestVoteQF(req *pb.RequestVoteRequest, replies []*pb.RequestVoteResponse) (*pb.RequestVoteResponse, bool)
RequestVoteQF gathers RequestVoteResponses and delivers a reply when a higher term is seen or a quorum of votes is received. TODO Implements gorums.QuorumSpec interface.