raft

package
v0.0.0-...-ca4665a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2016 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

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 lots leader status")

	// retuns when a raft internal message is too large to be sent
	ErrRequestTooLarge = errors.New("raft: raft messahe 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 not 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 (
	// IsLeader indicates that the node is a raft leader
	IsLeader LeadershipState = iota

	// IsFollower indicates that the node is a raft follower
	IsFollower
)

type Node

type Node struct {
	Config *raft.Config
	// contains filtered or unexported fields
}

func NewNode

func NewNode(id int, peers []string, store store.Store) *Node

func (*Node) IsIDRemoved

func (n *Node) IsIDRemoved(id uint64) bool

func (*Node) IsLeader

func (n *Node) IsLeader() bool

checks if we are the leader or not, with the protection of lock

func (*Node) IsMember

func (n *Node) IsMember() bool

checks if the raft node has effectively joined a cluster of existing member

func (*Node) Leader

func (n *Node) Leader() (uint64, error)

returns the is of the leader, with the protecttion of lock

func (*Node) LoadSnapshot

func (n *Node) LoadSnapshot()

func (*Node) Process

func (n *Node) Process(ctx context.Context, m raftpb.Message) error

func (*Node) ProposeValue

func (n *Node) ProposeValue(ctx context.Context, storeAction []*ztypes.StoreAction, cb func()) error

func (*Node) ReportSnapshot

func (n *Node) ReportSnapshot(id uint64, status raft.SnapshotStatus)

func (*Node) ReportUnreachable

func (n *Node) ReportUnreachable(id uint64)

func (*Node) Run

func (n *Node) Run(ctx context.Context) error

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 sate. If no saved sater exists. it starts a single-node cluster

func (*Node) StartRaft

func (n *Node) StartRaft(ctx context.Context) error

func (*Node) Status

func (n *Node) Status() raft.Status

returns status of underlying etcd.Node

func (*Node) SubscribeLeaderShip

func (n *Node) SubscribeLeaderShip() (q chan events.Event, cancel func())

func (*Node) WaitForLeader

func (n *Node) WaitForLeader(ctx context.Context) error

func (*Node) WithContext

func (n *Node) WithContext(ctx context.Context) (context.Context, context.CancelFunc)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL