本文整理汇总了Golang中goshawkdb/io/common/capnp.Action.Read方法的典型用法代码示例。如果您正苦于以下问题:Golang Action.Read方法的具体用法?Golang Action.Read怎么用?Golang Action.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类goshawkdb/io/common/capnp.Action
的用法示例。
在下文中一共展示了Action.Read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: combine
func (bra *badReadAction) combine(action *msgs.Action, rmBal *rmBallot, txnId *common.TxnId, clockElem uint64) {
newActionType := action.Which()
braActionType := bra.action.Which()
switch {
case braActionType != msgs.ACTION_READ && newActionType != msgs.ACTION_READ:
// They're both writes in some way. Just order the txns
if clockElem > bra.clockElem || (clockElem == bra.clockElem && bra.txnId.LessThan(txnId)) {
bra.set(action, rmBal, txnId, clockElem)
}
case braActionType == msgs.ACTION_READ && newActionType == msgs.ACTION_READ:
braRead := bra.action.Read()
newRead := action.Read()
clockElem--
// If they read the same version, we really don't care.
if !bytes.Equal(braRead.Version(), newRead.Version()) {
// They read different versions, but which version was the latter?
if clockElem > bra.clockElem {
bra.set(action, rmBal, common.MakeTxnId(newRead.Version()), clockElem)
}
}
case braActionType == msgs.ACTION_READ:
if bytes.Equal(bra.txnId[:], txnId[:]) {
// The write will obviously be in the past of the
// existing read, but it's better to have the write
// as we can update the client with the actual
// value.
bra.set(action, rmBal, txnId, clockElem)
} else if clockElem > bra.clockElem {
// The write is after than the read
bra.set(action, rmBal, txnId, clockElem)
}
default: // Existing is not a read, but new is a read.
newRead := action.Read()
clockElem--
// If the read is a read of the existing write, better to keep the write
if !bytes.Equal(bra.txnId[:], newRead.Version()) {
if clockElem > bra.clockElem {
// The read must be of some value which was written after our existing write.
bra.set(action, rmBal, common.MakeTxnId(newRead.Version()), clockElem)
}
}
}
}
示例2: translateRead
func (sts *SimpleTxnSubmitter) translateRead(action *msgs.Action, clientAction *msgs.ClientAction) {
action.SetRead()
clientRead := clientAction.Read()
read := action.Read()
read.SetVersion(clientRead.Version())
}