element/events.go

40 lines
1.0 KiB
Go

package element
import (
"github.com/hashicorp/memberlist"
)
// NodeEventType is the type of node event
type NodeEventType string
const (
// NodeJoin is the event fired upon a node joining the cluster
NodeJoin NodeEventType = "join"
// NodeLeave is the event fired upon a node leaving the cluster
NodeLeave NodeEventType = "leave"
// NodeUpdate is the event fired upon a node updating in the cluster
NodeUpdate NodeEventType = "update"
)
// NodeEvent stores the event type and node information
type NodeEvent struct {
// EventType is the type of event fired
EventType NodeEventType
// Node is the internal cluster node
Node *memberlist.Node
}
// NotifyJoin notifies when a node joins the cluster
func (a *Agent) NotifyJoin(n *memberlist.Node) {
}
// NotifyLeave notifies when a node leaves the cluster
func (a *Agent) NotifyLeave(n *memberlist.Node) {
delete(a.state.Peers, n.Name)
a.peerUpdateChan <- true
}
// NotifyUpdate notifies when a node is updated in the cluster
func (a *Agent) NotifyUpdate(n *memberlist.Node) {
}