raft

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: Apache-2.0 Imports: 31 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 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

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

func NewNode

func NewNode(opts NodeOptions) (*Node, error)

func (*Node) AddMember added in v0.1.3

func (n *Node) AddMember(ctx context.Context, swanNode api.Node) error

func (*Node) GetNodes added in v0.1.3

func (n *Node) GetNodes() ([]*swan.Node, error)

func (*Node) IsIDRemoved

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

func (*Node) IsLeader

func (n *Node) IsLeader() bool

checks if we are the leader of 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 exiting member

func (*Node) Leader

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

returns the id of leader, with the protection of lock

func (*Node) Process

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

func (*Node) ProposeValue

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

func (*Node) RemoveMember added in v0.1.3

func (n *Node) RemoveMember(ctx context.Context, raftID uint64) 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 state. If no saved stater exists. It start a single-node cluster

func (*Node) StartRaft

func (n *Node) StartRaft(ctx context.Context, peers []api.Node, isNewCluster bool) error

func (*Node) Status

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

returns status of underlying etcd.Node

func (*Node) SubcribeLeaderChange

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

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)

type NodeOptions added in v0.1.3

type NodeOptions struct {
	RaftID        uint64
	SwanNodeID    string
	ListenAddr    string
	AdvertiseAddr string
	DataDir       string
	DB            *store.BoltbDb
}

Directories

Path Synopsis
Package types is a generated protocol buffer package.
Package types is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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