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


Golang Message.From方法代碼示例

本文整理匯總了Golang中github.com/coreos/etcd/raft/raftpb.Message.From方法的典型用法代碼示例。如果您正苦於以下問題:Golang Message.From方法的具體用法?Golang Message.From怎麽用?Golang Message.From使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/coreos/etcd/raft/raftpb.Message的用法示例。


在下文中一共展示了Message.From方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: send

// send persists state to stable storage and then sends to its mailbox.
func (r *raft) send(m pb.Message) {
	m.From = r.id
	// do not attach term to MsgProp
	// proposals are a way to forward to the leader and
	// should be treated as local message.
	if m.Type != pb.MsgProp {
		m.Term = r.Term
	}
	r.msgs = append(r.msgs, m)
}
開發者ID:lebauce,項目名稱:skydive,代碼行數:11,代碼來源:raft.go

示例2: Send

// Send a message. Returns false if the message was dropped.
func (rttc *raftTransportTestContext) Send(
	from, to roachpb.ReplicaDescriptor, rangeID roachpb.RangeID, msg raftpb.Message,
) bool {
	msg.To = uint64(to.ReplicaID)
	msg.From = uint64(from.ReplicaID)
	req := &storage.RaftMessageRequest{
		RangeID:     rangeID,
		Message:     msg,
		ToReplica:   to,
		FromReplica: from,
	}
	return rttc.transports[from.NodeID].SendAsync(req)
}
開發者ID:bdarnell,項目名稱:cockroach,代碼行數:14,代碼來源:raft_transport_test.go

示例3: Send

// Send a message. Returns false if the message was dropped.
func (rttc *raftTransportTestContext) Send(
	from, to roachpb.ReplicaDescriptor, rangeID roachpb.RangeID, msg raftpb.Message,
) bool {
	msg.To = uint64(to.ReplicaID)
	msg.From = uint64(from.ReplicaID)
	req := &storage.RaftMessageRequest{
		RangeID:     rangeID,
		Message:     msg,
		ToReplica:   to,
		FromReplica: from,
	}
	sender := rttc.transports[from.NodeID].MakeSender(
		func(err error, _ roachpb.ReplicaDescriptor) {
			if err != nil && !grpcutil.IsClosedConnection(err) &&
				!testutils.IsError(err, channelServerBrokenRangeMessage) {
				rttc.t.Fatal(err)
			}
		})
	return sender.SendAsync(req)
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:21,代碼來源:raft_transport_test.go

示例4: send

// send persists state to stable storage and then sends to its mailbox.
func (r *raft) send(m pb.Message) {
	m.From = r.id
	if m.Type == pb.MsgVote || m.Type == pb.MsgPreVote {
		if m.Term == 0 {
			// PreVote RPCs are sent at a term other than our actual term, so the code
			// that sends these messages is responsible for setting the term.
			panic(fmt.Sprintf("term should be set when sending %s", m.Type))
		}
	} else {
		if m.Term != 0 {
			panic(fmt.Sprintf("term should not be set when sending %s (was %d)", m.Type, m.Term))
		}
		// do not attach term to MsgProp, MsgReadIndex
		// proposals are a way to forward to the leader and
		// should be treated as local message.
		// MsgReadIndex is also forwarded to leader.
		if m.Type != pb.MsgProp && m.Type != pb.MsgReadIndex {
			m.Term = r.Term
		}
	}
	r.msgs = append(r.msgs, m)
}
開發者ID:hongchaodeng,項目名稱:etcd,代碼行數:23,代碼來源:raft.go

示例5: send

// send persists state to stable storage and then sends to its mailbox.
func (r *raft) send(m pb.Message) {
	m.From = r.id
	m.Term = r.Term
	r.msgs = append(r.msgs, m)
}
開發者ID:b2ornot2b,項目名稱:etcd,代碼行數:6,代碼來源:raft.go


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