Documentation
¶
Index ¶
- Constants
- func GetNewRaft(logWriter *os.File, dataDir, raftAddr string, raftPort int, fsm raft.FSM) (*raft.Raft, error)
- func GetNewSerf(logWriter *os.File, dataDir, serfAddr string, serfPort int, ...) (*serf.Serf, error)
- func IsMemberEventFailed(event serf.MemberEvent) bool
- type Action
- type EventsFSM
- func (f *EventsFSM) Apply(l *raft.Log) interface{}
- func (fsm *EventsFSM) DiscardTopEvent()
- func (fsm *EventsFSM) EnqueueEvent(ev string)
- func (fsm *EventsFSM) HandleAction(a *Action)
- func (f *EventsFSM) Restore(snap io.ReadCloser) error
- func (f *EventsFSM) Snapshot() (raft.FSMSnapshot, error)
- func (fsm *EventsFSM) TopEvent() string
- type SerfDB
- type SerfPeer
Constants ¶
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 EventsFSM ¶
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) DiscardTopEvent ¶
func (fsm *EventsFSM) DiscardTopEvent()