本文整理汇总了Golang中github.com/hashicorp/serf/serf.MemberEvent类的典型用法代码示例。如果您正苦于以下问题:Golang MemberEvent类的具体用法?Golang MemberEvent怎么用?Golang MemberEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemberEvent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sendMemberEvent
// sendMemberEvent is used to send a single member event
func (es *eventStream) sendMemberEvent(me serf.MemberEvent) error {
members := make([]Member, 0, len(me.Members))
for _, m := range me.Members {
sm := Member{
Name: m.Name,
Addr: m.Addr,
Port: m.Port,
Tags: m.Tags,
Status: m.Status.String(),
ProtocolMin: m.ProtocolMin,
ProtocolMax: m.ProtocolMax,
ProtocolCur: m.ProtocolCur,
DelegateMin: m.DelegateMin,
DelegateMax: m.DelegateMax,
DelegateCur: m.DelegateCur,
}
members = append(members, sm)
}
header := responseHeader{
Seq: es.seq,
Error: "",
}
rec := memberEventRecord{
Event: me.String(),
Members: members,
}
return es.client.Send(&header, &rec)
}
示例2: localMemberEvent
// localMemberEvent is used to reconcile Serf events with the strongly
// consistent store if we are the current leader
func (s *Server) localMemberEvent(me serf.MemberEvent) {
// Do nothing if we are not the leader
if !s.IsLeader() {
return
}
// Check if this is a reap event
isReap := me.EventType() == serf.EventMemberReap
// Queue the members for reconciliation
for _, m := range me.Members {
// Change the status if this is a reap event
if isReap {
m.Status = StatusReap
}
select {
case s.reconcileCh <- m:
default:
}
}
}
示例3: reconcile
// reconcile is used to reconcile Serf events with the strongly
// consistent store if we are the current leader
func (s *SerfEventHandler) reconcile(me serf.MemberEvent) {
// Do nothing if we are not the leader.
if !s.IsLeader() {
return
}
// Check if this is a reap event
isReap := me.EventType() == serf.EventMemberReap
// Queue the members for reconciliation
for _, m := range me.Members {
// Change the status if this is a reap event
if isReap {
m.Status = StatusReap
}
// Call reconcile
if s.Reconciler != nil {
s.Reconciler.Reconcile(m)
}
}
}