raftor

package module
v0.0.0-...-32ab2e7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

README

raftor GoDoc

Raftor is an abstraction layer above etcd's raft implementation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applier

type Applier interface {

	// Apply processes commit messages after being processed by Raft
	Apply(Commit)
}

Applier applies either a snapshot or entries in a Commit object

type Cluster

type Cluster interface {
	Notifier
	Applier
	Updater

	// ID represents the cluster ID.
	ID() uint64

	// Name returns the Cluster's name.
	Name() string

	// GetMember returns a Member instance based on it's ID.
	GetMember(uint64) Member

	// IsBanished checks whether the given ID has been removed from this
	// cluster at some point in the past.
	IsBanished(id uint64) bool

	// LocalNode returns the RaftNode which represents the local node of the cluster.
	LocalNode() RaftNode

	// Stop stops the cluster and triggers the context when finished.
	Stop(context.Context)
}

Cluster maintains an active list of nodes in the cluster. Cluster is also responsible for reporting and responding to changes in cluster membership.

type ClusterChangeEvent

type ClusterChangeEvent struct {
	Type   ClusterEventType
	Member Member
}

ClusterChangeEvent is used to store details about a cluster change. It is sent when a new node is detected and after the change has been applied to a raft log.

type ClusterChangeHandler

type ClusterChangeHandler interface {

	// HandleJoin is called when a node joins the cluster.
	HandleJoin(ClusterChangeEvent)

	// HandleJoin is called when a node leaves the cluster.
	HandleLeave(ClusterChangeEvent)

	// HandleJoin is called when a node is updated.
	HandleUpdate(ClusterChangeEvent)
}

ClusterChangeHandler is used to process ClusterChangeEvents.

type ClusterConfig

type ClusterConfig struct {
	Name string
	Raft raft.Config
}

ClusterConfig helps to configure a RaftNode

type ClusterEventType

type ClusterEventType uint8

ClusterEventType is an enum describing how the cluster is changing.

const (
	// AddMember is used to describe a cluster change when a node is added.
	AddMember ClusterEventType = iota

	// RemoveMember is used to describe a cluster change when a node is removed.
	RemoveMember

	// UpdateMember is used to describe a cluster change when a node is updated.
	UpdateMember
)

type Commit

type Commit struct {
	State    RaftState
	Entries  []raftpb.Entry
	Snapshot raftpb.Snapshot
	Messages []raftpb.Message
	Context  context.Context
}

Commit is used to send to the cluster to save either a snapshot or log entries.

type Member

type Member interface {
	ID() uint64
	Meta() []byte
}

Member describes a node in the cluster

func NewMember

func NewMember(id uint64, meta []byte) Member

NewMember creates a new member type

type Notifier

type Notifier interface {

	// Notify returns a read-only channel of ClusterChangeEvents which can be read when a node joins, leaves or is updated in the cluster.
	Notify(ClusterChangeEvent)
}

Notifier notifies the receiver of the cluster change.

type RaftNode

type RaftNode interface {
	raft.Node
	Starter
}

RaftNode extends the etcd raft.Node

type RaftState

type RaftState struct {
	CommitID             uint64
	Vote                 uint64
	Term                 uint64
	Lead                 uint64
	LastLeadElectionTime time.Time
	RaftState            raft.StateType
}

RaftState describes the state of the Raft cluster for each commit

type Starter

type Starter interface {
	Start()
}

Starter starts whatever you need to be started

type Stopper

type Stopper interface {
	Stop() <-chan struct{}
}

Stopper stops whatever you need to be stopped. It is meant to be used inside a select statement.

type Updater

type Updater interface {

	// Update is called after the ClusterChangeEvent has been processed and stored by Raft.
	Update(ClusterChangeEvent)
}

Updater applies cluster change events

Directories

Path Synopsis
Godeps
_workspace/src/github.com/coreos/etcd/raft
Package raft provides an implementation of the raft consensus algorithm.
Package raft provides an implementation of the raft consensus algorithm.
_workspace/src/github.com/coreos/etcd/raft/raftpb
Package raftpb is a generated protocol buffer package.
Package raftpb is a generated protocol buffer package.
_workspace/src/github.com/gogo/protobuf/proto
Package proto converts data structures to and from the wire format of protocol buffers.
Package proto converts data structures to and from the wire format of protocol buffers.
_workspace/src/github.com/gogo/protobuf/proto/proto3_proto
Package proto3_proto is a generated protocol buffer package.
Package proto3_proto is a generated protocol buffer package.
_workspace/src/golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
pkg
memberlist
Package memberlist implements the raftor.ClusterChangeNotifier interface along with the memberlist.EventDelegate interface.
Package memberlist implements the raftor.ClusterChangeNotifier interface along with the memberlist.EventDelegate interface.

Jump to

Keyboard shortcuts

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