本文整理汇总了Golang中goshawkdb/io/common/capnp.Txn.Id方法的典型用法代码示例。如果您正苦于以下问题:Golang Txn.Id方法的具体用法?Golang Txn.Id怎么用?Golang Txn.Id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类goshawkdb/io/common/capnp.Txn
的用法示例。
在下文中一共展示了Txn.Id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TxnFromCap
func TxnFromCap(exe *dispatcher.Executor, vd *VarDispatcher, stateChange TxnLocalStateChange, ourRMId common.RMId, txnCap *msgs.Txn) *Txn {
txnId := common.MakeTxnId(txnCap.Id())
actions := txnCap.Actions()
txn := &Txn{
Id: txnId,
Retry: txnCap.Retry(),
writes: make([]*common.VarUUId, 0, actions.Len()),
TxnCap: txnCap,
exe: exe,
vd: vd,
stateChange: stateChange,
}
allocations := txnCap.Allocations()
for idx, l := 0, allocations.Len(); idx < l; idx++ {
alloc := allocations.At(idx)
rmId := common.RMId(alloc.RmId())
if ourRMId == rmId {
txn.populate(alloc.ActionIndices(), actions)
break
}
}
return txn
}
示例2: deflateTxn
func deflateTxn(txn *msgs.Txn, seg *capn.Segment) *msgs.Txn {
if isDeflated(txn) {
return txn
}
deflatedTxn := msgs.NewTxn(seg)
deflatedTxn.SetId(txn.Id())
deflatedTxn.SetRetry(txn.Retry())
deflatedTxn.SetSubmitter(txn.Submitter())
deflatedTxn.SetSubmitterBootCount(txn.SubmitterBootCount())
deflatedTxn.SetFInc(txn.FInc())
deflatedTxn.SetTopologyVersion(txn.TopologyVersion())
deflatedTxn.SetAllocations(txn.Allocations())
actionsList := txn.Actions()
deflatedActionsList := msgs.NewActionList(seg, actionsList.Len())
deflatedTxn.SetActions(deflatedActionsList)
for idx, l := 0, actionsList.Len(); idx < l; idx++ {
deflatedAction := deflatedActionsList.At(idx)
deflatedAction.SetVarId(actionsList.At(idx).VarId())
deflatedAction.SetMissing()
}
return &deflatedTxn
}
示例3: TxnToRootBytes
func TxnToRootBytes(txn *msgs.Txn) []byte {
seg := capn.NewBuffer(nil)
txnCap := msgs.NewRootTxn(seg)
txnCap.SetId(txn.Id())
txnCap.SetRetry(txn.Retry())
txnCap.SetSubmitter(txn.Submitter())
txnCap.SetSubmitterBootCount(txn.SubmitterBootCount())
txnCap.SetActions(txn.Actions())
txnCap.SetAllocations(txn.Allocations())
txnCap.SetFInc(txn.FInc())
txnCap.SetTopologyVersion(txn.TopologyVersion())
return server.SegToBytes(seg)
}
示例4: SubmitTransaction
func (sts *SimpleTxnSubmitter) SubmitTransaction(txnCap *msgs.Txn, activeRMs []common.RMId, continuation TxnCompletionConsumer, delay time.Duration) {
seg := capn.NewBuffer(nil)
msg := msgs.NewRootMessage(seg)
msg.SetTxnSubmission(*txnCap)
txnId := common.MakeTxnId(txnCap.Id())
server.Log(txnId, "Submitting txn")
txnSender := paxos.NewRepeatingSender(server.SegToBytes(seg), activeRMs...)
if delay == 0 {
sts.connectionManager.AddSender(txnSender)
} else {
go func() {
// fmt.Printf("%v ", delay)
time.Sleep(delay)
sts.connectionManager.AddSender(txnSender)
}()
}
acceptors := paxos.GetAcceptorsFromTxn(txnCap)
shutdownFun := func(shutdown bool) {
delete(sts.outcomeConsumers, *txnId)
// fmt.Printf("sts%v ", len(sts.outcomeConsumers))
sts.connectionManager.RemoveSenderAsync(txnSender)
paxos.NewOneShotSender(paxos.MakeTxnSubmissionCompleteMsg(txnId), sts.connectionManager, acceptors...)
if shutdown {
if txnCap.Retry() {
paxos.NewOneShotSender(paxos.MakeTxnSubmissionAbortMsg(txnId), sts.connectionManager, activeRMs...)
}
continuation(txnId, nil)
}
}
shutdownFunPtr := &shutdownFun
sts.onShutdown[shutdownFunPtr] = server.EmptyStructVal
outcomeAccumulator := paxos.NewOutcomeAccumulator(int(txnCap.FInc()), acceptors)
consumer := func(sender common.RMId, txnId *common.TxnId, outcome *msgs.Outcome) {
if outcome, _ = outcomeAccumulator.BallotOutcomeReceived(sender, outcome); outcome != nil {
delete(sts.onShutdown, shutdownFunPtr)
shutdownFun(false)
continuation(txnId, outcome)
}
}
sts.outcomeConsumers[*txnId] = consumer
// fmt.Printf("sts%v ", len(sts.outcomeConsumers))
}
示例5: TxnReceived
func (pd *ProposerDispatcher) TxnReceived(sender common.RMId, txn *msgs.Txn) {
txnId := common.MakeTxnId(txn.Id())
pd.withProposerManager(txnId, func(pm *ProposerManager) { pm.TxnReceived(txnId, txn) })
}