Documentation ¶
Index ¶
- func IsInternalError(err error) bool
- func MakeInternalError(err error) error
- type AbortInstruction
- type ApplyInstruction
- type Driver
- type Index
- type Instruction
- type InternalError
- type Log
- func (l *Log) Append(term Term, command []byte) (Index, error)
- func (l *Log) Commit(index Index) error
- func (l *Log) CommitIndex() (Index, Term)
- func (l *Log) Get(index Index) (*raftpb.Entry, error)
- func (l *Log) GetTerm() (_ Term, votedFor NodeID, _ error)
- func (l *Log) Has(index Index, term Term) (bool, error)
- func (l *Log) LastIndex() (Index, Term)
- func (l *Log) Scan(start, end Index) (itertools.Iterator[*raftpb.Entry], error)
- func (l *Log) SetTerm(term Term, votedFor NodeID) error
- func (l *Log) Splice(entries []*raftpb.Entry) (Index, error)
- func (l *Log) Status() (*storagepb.EngineStatus, error)
- type Node
- type NodeID
- type Notify
- type NotifyInstruction
- type Query
- type QueryInstruction
- type RequestID
- type Role
- type Server
- func (s *Server) Mutate(ctx context.Context, command []byte) ([]byte, error)
- func (s *Server) Query(ctx context.Context, command []byte) ([]byte, error)
- func (s *Server) SendMessages(stream raftpb.Raft_SendMessagesServer) error
- func (s *Server) Serve(ctx context.Context) error
- func (s *Server) Status(ctx context.Context) (*raftpb.Status, error)
- type State
- type StatusInstruction
- type Term
- type VoteInstruction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInternalError ¶
func MakeInternalError ¶
Types ¶
type AbortInstruction ¶
type AbortInstruction struct{}
AbortInstruction is the instruction to abort any pending operations.
type ApplyInstruction ¶
ApplyInstruction is the instruction to apply a log entry.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is a driver for driving the raft state machine. Taking operations from the stateCh and sending results via the nodeCh.
type Instruction ¶
type Instruction interface {
// contains filtered or unexported methods
}
Instruction is the instructions sent to driver.
type InternalError ¶
type InternalError struct {
// contains filtered or unexported fields
}
InternalError is an error that is used to wrap internal errors. It is used to distinguish internal errors from user errors.
func (*InternalError) Error ¶
func (e *InternalError) Error() string
func (*InternalError) Unwrap ¶
func (e *InternalError) Unwrap() error
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is a persistent log of entries. It is the source of truth for the state machine. Each entry is identified by its index and term.
func (*Log) CommitIndex ¶
func (*Log) Splice ¶
Splice splices a set log entries into the log and returns the index of the last entry.
The entries must be contiguous, and the first entry's index must be at most lastIndex+1 and at least commitIndex+1. When splicing, the log will overwrite any existing entries and truncate any existing entries after the last spliced entry.
type NotifyInstruction ¶
NotifyInstruction is the instruction to notify the given node with the result of applying the entry at the given index.
type Query ¶
type QueryInstruction ¶
type QueryInstruction struct { ID RequestID NodeID NodeID Command RequestID Term Term Index Index Quorum int }
QueryInstruction is the instruction to query the state machine when the given term and index has been confirmed by vote.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) SendMessages ¶
func (s *Server) SendMessages(stream raftpb.Raft_SendMessagesServer) error
type State ¶
type State interface { // AppliedIndex returns the last applied index. AppliedIndex() Index // Apply applies a log to the state machine. Apply should // be deterministic and idempotent. // // If InternalError is returned, the raft node will be terminated. // Any other error is considered applied and returned to the caller. Apply(entry *raftpb.Entry) ([]byte, error) // Query queries the state machine with the given command. Query(command []byte) ([]byte, error) }
State represents a raft state machine. The caller of raft is responsible for implementing the state machine.
type StatusInstruction ¶
StatusQuery is the instruction to extend the given server status and return it the the given node.
type VoteInstruction ¶
VoteInstruction is the instruction to vote for the given term and index.