Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Consensus
- func (c *Consensus) Apply(record *raft.Log) interface{}
- func (c *Consensus) Close() error
- func (c *Consensus) Exec(req *pb.Request) ([]*pb.ExecRes, error)
- func (c *Consensus) GetServers() ([]*pb.Server, error)
- func (c *Consensus) IsLeader() bool
- func (c *Consensus) Join(id, addr string) error
- func (c *Consensus) LeaderAddr() string
- func (c *Consensus) Leave(id string) error
- func (c *Consensus) Metrics() (map[string]any, error)
- func (c *Consensus) Query(q *pb.QueryReq) ([]*pb.QueryRes, error)
- func (c *Consensus) Restore(rc io.ReadCloser) error
- func (c *Consensus) Snapshot() (raft.FSMSnapshot, error)
- func (c *Consensus) WaitForIndex(idx uint64, timeout time.Duration) (uint64, error)
- func (c *Consensus) WaitForLeader(timeout time.Duration) error
- type RequestType
- type Transport
Constants ¶
View Source
const ( ExecRequest RequestType = iota // RaftRPC is given at the start of connection to signify that raft should handle that connection. RaftRPC int = 1 )
Variables ¶
View Source
var ( // ErrNotLeader defines a project-wide not leader error ErrNotLeader = errors.New("not raft leader") // ErrJoinSelf happens when a node tries to join itself. ErrJoinSelf = errors.New("trying to join self") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Raft struct { raft.Config Bootstrap bool SnapshotThreshold uint64 } Transport *Transport }
Config configures parts of raft and also transport that is used.
type Consensus ¶
type Consensus struct {
// contains filtered or unexported fields
}
func (*Consensus) LeaderAddr ¶
func (*Consensus) WaitForIndex ¶
type RequestType ¶
type RequestType uint8
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport handles communications between different raft nodes.
func NewTLSTransport ¶
NewTLSTransport creates a transport instance with the tls fields populated.
func NewTransport ¶
NewTransport creates a new transport instance.
func (*Transport) Accept ¶
Accept acceps a given dial and checks that the RaftRPC identifier is defined at the start; if not then just return an error.
Click to show internal directories.
Click to hide internal directories.