當前位置: 首頁>>代碼示例>>Golang>>正文


Golang serf.MemberEvent類代碼示例

本文整理匯總了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)
}
開發者ID:KushalP,項目名稱:serf,代碼行數:30,代碼來源:ipc_event_stream.go

示例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:
		}
	}
}
開發者ID:robxu9,項目名稱:consul,代碼行數:23,代碼來源:serf.go

示例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)
		}
	}
}
開發者ID:blacklabeldata,項目名稱:serfer,代碼行數:25,代碼來源:handler.go


注:本文中的github.com/hashicorp/serf/serf.MemberEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。