本文整理汇总了Golang中proto-ascent/paxos/classic.PaxosMessage.LearnResponse方法的典型用法代码示例。如果您正苦于以下问题:Golang PaxosMessage.LearnResponse方法的具体用法?Golang PaxosMessage.LearnResponse怎么用?Golang PaxosMessage.LearnResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proto-ascent/paxos/classic.PaxosMessage
的用法示例。
在下文中一共展示了PaxosMessage.LearnResponse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: LearnRPC
// LearnRPC handles ClassicPaxos.Learn rpc.
func (this *Paxos) LearnRPC(header *msgpb.Header,
request *thispb.LearnRequest) (status error) {
if !this.IsLearner() {
this.Errorf("this paxos instance is not a learner; rejecting %s", header)
return errs.ErrInvalid
}
lock, errLock := this.ctlr.TimedLock(msg.RequestTimeout(header), "learner")
if errLock != nil {
return errLock
}
defer lock.Unlock()
acceptor := header.GetMessengerId()
if this.chosenValue == nil {
change := thispb.LearnerChange{}
change.VotedBallotList = request.VotedBallotList
change.VotedValueList = request.VotedValueList
change.VotedAcceptor = proto.String(acceptor)
if err := this.doUpdateLearner(&change); err != nil {
this.Errorf("could not update learner state: %v", err)
return err
}
}
response := thispb.LearnResponse{}
if this.chosenValue != nil {
response.KnowsChosenValue = proto.Bool(true)
}
message := thispb.PaxosMessage{}
message.LearnResponse = &response
errSend := msg.SendResponseProto(this.msn, header, &message)
if errSend != nil {
this.Errorf("could not respond to learn request from %s: %v", acceptor,
errSend)
return errSend
}
return nil
}