lib

package
v0.0.0-...-7f9db45 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnqueueCmd = "enqueue"
	DiscardCmd = "discard"
)

Variables

This section is empty.

Functions

func GetNewRaft

func GetNewRaft(logWriter *os.File, dataDir, raftAddr string, raftPort int, fsm raft.FSM) (*raft.Raft, error)

GetNewRaft returns the default Raft object, which includes for example, a local ID, FSM(Finite State Machine), logstore and snapshotstore, and a TCP transport.

func GetNewSerf

func GetNewSerf(logWriter *os.File, dataDir, serfAddr string, serfPort int, serfEvents chan serf.Event) (*serf.Serf, error)

GetNewSerf returns the default Serf object, which includes for example, memberlist configs (like bind address, bind port), node name, event channel.

func IsMemberEventFailed

func IsMemberEventFailed(event serf.MemberEvent) bool

IsMemberEventFailed returns true if the given Serf member event is one of the following event types: leave, failed, or reap. It will be typically used for synchronizing status of a remote peer that has gone out of the Serf peers.

Types

type Action

type Action struct {
	Cmd   string `json:"cmd"`
	Event string `json:"event"`
}

type EventsFSM

type EventsFSM struct {
	sync.Mutex

	Events []string
}

EventsFSM is a Finite State Machine representing events (for now they're stored as simple strings).

The raft library uses an FSM as an abstraction to allow the current state of the cluster to be replicated to other nodes. We implement the Apply() operation defined in the FSM interface to take advantage of this.

Since restoring the state of the FSM must result in the same state as a full replay of the raft logs, the raft library can capture the FSM state at a point in time and then remove all the logs used to reach that state, this is performed automatically to avoid unbound log growth. We implement the Snapshot() and Restore() operations defined in the FSM interface and the Persist() operation defined in the FSMSnapshot interface to take advantage of this.

func NewEventsFSM

func NewEventsFSM() *EventsFSM

func (*EventsFSM) Apply

func (f *EventsFSM) Apply(l *raft.Log) interface{}

func (*EventsFSM) DiscardTopEvent

func (fsm *EventsFSM) DiscardTopEvent()

func (*EventsFSM) EnqueueEvent

func (fsm *EventsFSM) EnqueueEvent(ev string)

func (*EventsFSM) HandleAction

func (fsm *EventsFSM) HandleAction(a *Action)

func (*EventsFSM) Restore

func (f *EventsFSM) Restore(snap io.ReadCloser) error

func (*EventsFSM) Snapshot

func (f *EventsFSM) Snapshot() (raft.FSMSnapshot, error)

func (*EventsFSM) TopEvent

func (fsm *EventsFSM) TopEvent() string

type SerfDB

type SerfDB struct {
	BoltDB         *bolt.DB
	SerfKeyPeers   string
	SerfBucketName string
}

SerfDB holds necessary information for accessing to Serf's BoltDB. BoltDB is a pointer for directly accessing the underlying database. SerfKeyPeers is the key to retrieve the Serf peers from the DB. SerfBucketName is the BoltDB bucket name for Serf data.

type SerfPeer

type SerfPeer struct {
	Address  string `json:"address,omitempty"`
	PeerName string `json:"nodename,omitempty"`
}

SerfPeer holds the name and IP address of a Serf peer.

Jump to

Keyboard shortcuts

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