Documentation ¶
Overview ¶
Serfer is a simple library which provides interfaces for handling various Serf events.
This allows for an encapsulation of more complex event processing logic by using separate event handlers based on event type.
Index ¶
Constants ¶
const ( // StatusReap is used to update the status of a node if we // are handling a EventMemberReap StatusReap = serf.MemberStatus(-1) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventHandler ¶
EventHandler processes generic Serf events. Depending on the event type, more processing may be needed.
type IsLeaderFunc ¶
type IsLeaderFunc func() bool
IsLeaderFunc should return true if the local node is the cluster leader.
type MemberEventHandler ¶
type MemberEventHandler interface {
HandleMemberEvent(serf.MemberEvent)
}
MemberEventHandler handles membership change events.
type QueryEventHandler ¶
QueryEventHandler handles Serf query events.
type Reconciler ¶
Reconciler is used to reconcile Serf events wilth an external process, like Raft.
type SerfEventHandler ¶
type SerfEventHandler struct { // ServicePrefix is used to filter out unknown events. ServicePrefix string // ReconcileOnJoin determines if the Reconiler is called when a node joins the cluster. ReconcileOnJoin bool // ReconcileOnLeave determines if the Reconiler is called when a node leaves the cluster. ReconcileOnLeave bool // ReconcileOnFail determines if the Reconiler is called when a node fails. ReconcileOnFail bool // ReconcileOnUpdate determines if the Reconiler is called when a node updates. ReconcileOnUpdate bool // ReconcileOnReap determines if the Reconiler is called when a node is reaped from the cluster. ReconcileOnReap bool // IsLeader determines if the local node is the cluster leader. IsLeader IsLeaderFunc // IsLeaderEventFunc determines if an event is a leader election event based on the event name. IsLeaderEvent func(string) bool // LeaderElectionHandler processes leader election events. LeaderElectionHandler UserEventHandler // UserEvent processes known, non-leader election events. UserEvent UserEventHandler // UnknownEventHandler processes unkown events. UnknownEventHandler UserEventHandler // Called when a Member joins the cluster. NodeJoined MemberEventHandler // Called when a Member leaves the cluster by sending a leave message. NodeLeft MemberEventHandler // Called when a Member has been detected as failed. NodeFailed MemberEventHandler // Called when a Member has been Readed from the cluster. NodeReaped MemberEventHandler // Called when a Member has been updated. NodeUpdated MemberEventHandler // Called when a membership event occurs. Reconciler Reconciler // Called when a serf.Query is received. QueryHandler QueryEventHandler // Logs output Logger log.Logger }
SerfEventHandler is used to dispatch various Serf events to separate event handlers.
func (SerfEventHandler) HandleEvent ¶
func (s SerfEventHandler) HandleEvent(e serf.Event)
HandleEvent processes a generic Serf event and dispatches it to the appropriate destination.
type Serfer ¶
type Serfer interface { // Start starts the serfer goroutine. Start() // Stop stops all event processing and blocks until finished. Stop() error }
Serfer processes Serf.Events and is meant to be ran in a goroutine.
type UserEventHandler ¶
UserEventHandler handles user events.