Documentation ¶
Index ¶
- Constants
- Variables
- type LeadershipState
- type Node
- func (n *Node) AddMember(ctx context.Context, swanNode api.Node) error
- func (n *Node) GetNodes() ([]*swan.Node, error)
- func (n *Node) IsIDRemoved(id uint64) bool
- func (n *Node) IsLeader() bool
- func (n *Node) IsMember() bool
- func (n *Node) Leader() (uint64, error)
- func (n *Node) Process(ctx context.Context, m raftpb.Message) error
- func (n *Node) ProposeValue(ctx context.Context, actions []*swan.StoreAction, cb func()) error
- func (n *Node) RemoveMember(ctx context.Context, raftID uint64) error
- func (n *Node) ReportSnapshot(id uint64, status raft.SnapshotStatus)
- func (n *Node) ReportUnreachable(id uint64)
- func (n *Node) Run(ctx context.Context) error
- func (n *Node) StartRaft(ctx context.Context, peers []api.Node, isNewCluster bool) error
- func (n *Node) Status() raft.Status
- func (n *Node) SubcribeLeaderChange() (q chan events.Event, cancel func())
- func (n *Node) SubscribeLeadership() (q chan events.Event, cancel func())
- func (n *Node) WaitForLeader(ctx context.Context) error
- func (n *Node) WithContext(ctx context.Context) (context.Context, context.CancelFunc)
- type NodeOptions
Constants ¶
View Source
const (
MaxTransactionBytes = 1.5 * 1024 * 1024
)
Variables ¶
View Source
var ( // returns when an operation was submitted but the node was stopped in the meantime ErrStopped = errors.New("raft: failed to process the request: node is stopped") // returns when an operation was submitted but the node lost leader status before it became committed ErrLostLeadership = errors.New("raft: failed to process the request: node losts leader status") // returns when a raft internal message is too large to be send ErrRequestToolarge = errors.New("raft: raft message is too large and can't be send") // returns when the node is not yet part of a raft cluster ErrNoRaftMember = errors.New("raft: node is mnot yet part of a raft cluster") // returns when the cluster has no elected leader ErrNoClusterLeader = errors.New("raft: no elected cluster leader") )
Functions ¶
This section is empty.
Types ¶
type LeadershipState ¶
type LeadershipState int
const ( // indicates that the node is a raft leader IsLeader LeadershipState = iota // indicates that the node is a raft follower IsFollower )
type Node ¶
func NewNode ¶
func NewNode(opts NodeOptions) (*Node, error)
func (*Node) IsIDRemoved ¶
func (*Node) ProposeValue ¶
func (*Node) RemoveMember ¶ added in v0.1.3
func (*Node) ReportSnapshot ¶
func (n *Node) ReportSnapshot(id uint64, status raft.SnapshotStatus)
func (*Node) ReportUnreachable ¶
func (*Node) Run ¶
Run is the main loop for a raft node it goes along the state machine action on the messages received from other raft nodes in the cluster TODO(upccup) Before running the main loop it first starts the raft node based on saved cluster state. If no saved stater exists. It start a single-node cluster
func (*Node) SubcribeLeaderChange ¶
func (*Node) SubscribeLeadership ¶
func (*Node) WithContext ¶
Click to show internal directories.
Click to hide internal directories.