Documentation ¶
Index ¶
- Variables
- type Node
- func (n *Node) AddToCluster(ctx context.Context, pid uint64) error
- func (n *Node) BatchAndSendMessages()
- func (n *Node) ConfState() *raftpb.ConfState
- func (n *Node) Connect(pid uint64, addr string)
- func (n *Node) DeletePeer(pid uint64)
- func (n *Node) InitFromWal(wal *raftwal.Wal) (idx uint64, restart bool, rerr error)
- func (n *Node) Peer(pid uint64) (string, bool)
- func (n *Node) ProposePeerRemoval(ctx context.Context, id uint64) error
- func (n *Node) Raft() raft.Node
- func (n *Node) SaveToStorage(s raftpb.Snapshot, h raftpb.HardState, es []raftpb.Entry)
- func (n *Node) Send(m raftpb.Message)
- func (n *Node) SetConfState(cs *raftpb.ConfState)
- func (n *Node) SetPeer(pid uint64, addr string)
- func (n *Node) SetRaft(r raft.Node)
- func (n *Node) WaitForMinProposal(ctx context.Context, read *protos.LinRead) error
- type Pool
- type Pools
- type RaftServer
- func (w *RaftServer) Echo(ctx context.Context, in *protos.Payload) (*protos.Payload, error)
- func (w *RaftServer) GetNode() *Node
- func (w *RaftServer) JoinCluster(ctx context.Context, rc *protos.RaftContext) (*protos.Payload, error)
- func (w *RaftServer) RaftMessage(ctx context.Context, query *protos.Payload) (*protos.Payload, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoConnection = fmt.Errorf("No connection exists") ErrUnhealthyConnection = fmt.Errorf("Unhealthy connection") )
var (
ErrDuplicateRaftId = x.Errorf("Node is already part of group")
)
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { x.SafeMutex // Fields which are never changed after init. Cfg *raft.Config MyAddr string Id uint64 RaftContext *protos.RaftContext Store *raft.MemoryStorage Wal *raftwal.Wal // applied is used to keep track of the applied RAFT proposals. // The stages are proposed -> committed (accepted by cluster) -> // applied (to PL) -> synced (to RocksDB). Applied x.WaterMark // contains filtered or unexported fields }
func NewNode ¶
func NewNode(rc *protos.RaftContext) *Node
func (*Node) BatchAndSendMessages ¶
func (n *Node) BatchAndSendMessages()
func (*Node) Connect ¶
Connects the node and makes its peerPool refer to the constructed pool and address (possibly updating ourselves from the old address.) (Unless pid is ourselves, in which case this does nothing.)
func (*Node) DeletePeer ¶
func (*Node) InitFromWal ¶
func (*Node) ProposePeerRemoval ¶
func (*Node) SaveToStorage ¶
func (*Node) SetConfState ¶
SetConfState would store the latest ConfState generated by ApplyConfChange.
type Pool ¶
"Pool" is used to manage the grpc client connection(s) for communicating with other worker instances. Right now it just holds one of them.
func (*Pool) Get ¶
func (p *Pool) Get() *grpc.ClientConn
Get returns the connection to use from the pool of connections.
func (*Pool) MonitorHealth ¶
func (p *Pool) MonitorHealth()
MonitorHealth monitors the health of the connection via Echo. This function blocks forever.
type RaftServer ¶
type RaftServer struct { Node *Node // contains filtered or unexported fields }
func (*RaftServer) Echo ¶
Hello rpc call is used to check connection with other workers after worker tcp server for this instance starts.
func (*RaftServer) GetNode ¶
func (w *RaftServer) GetNode() *Node
func (*RaftServer) JoinCluster ¶
func (w *RaftServer) JoinCluster(ctx context.Context, rc *protos.RaftContext) (*protos.Payload, error)