本文整理匯總了Golang中github.com/cockroachdb/cockroach/roachpb.ReplicaDescriptor.Validate方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReplicaDescriptor.Validate方法的具體用法?Golang ReplicaDescriptor.Validate怎麽用?Golang ReplicaDescriptor.Validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/roachpb.ReplicaDescriptor
的用法示例。
在下文中一共展示了ReplicaDescriptor.Validate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ChangeGroupMembership
// ChangeGroupMembership submits a proposed membership change to the cluster.
// Payload is an opaque blob that will be returned in EventMembershipChangeCommitted.
func (m *MultiRaft) ChangeGroupMembership(groupID roachpb.RangeID, commandID string,
changeType raftpb.ConfChangeType, replica roachpb.ReplicaDescriptor, payload []byte) <-chan error {
if log.V(6) {
log.Infof("node %v proposing membership change to group %v", m.nodeID, groupID)
}
ch := make(chan error, 1)
if err := replica.Validate(); err != nil {
ch <- err
return ch
}
m.proposalChan <- &proposal{
groupID: groupID,
commandID: commandID,
fn: func() {
ctx := ConfChangeContext{
CommandID: commandID,
Payload: payload,
Replica: replica,
}
encodedCtx, err := ctx.Marshal()
if err != nil {
log.Errorf("node %v: error encoding context protobuf", m.nodeID)
return
}
if err := m.multiNode.ProposeConfChange(context.Background(), uint64(groupID),
raftpb.ConfChange{
Type: changeType,
NodeID: uint64(replica.ReplicaID),
Context: encodedCtx,
},
); err != nil {
log.Errorf("node %v: error proposing membership change to node %v: %s", m.nodeID,
groupID, err)
return
}
},
ch: ch,
}
return ch
}