本文整理匯總了Golang中github.com/cockroachdb/cockroach/internal/client.DB.Run方法的典型用法代碼示例。如果您正苦於以下問題:Golang DB.Run方法的具體用法?Golang DB.Run怎麽用?Golang DB.Run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/internal/client.DB
的用法示例。
在下文中一共展示了DB.Run方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: pushTxn
// pushTxn attempts to abort the txn via push. The wait group is signaled on
// completion.
func pushTxn(db *client.DB, now hlc.Timestamp, txn *roachpb.Transaction,
typ roachpb.PushTxnType) {
// Attempt to push the transaction which created the intent.
pushArgs := &roachpb.PushTxnRequest{
Span: roachpb.Span{
Key: txn.Key,
},
Now: now,
PusherTxn: roachpb.Transaction{TxnMeta: enginepb.TxnMeta{Priority: math.MaxInt32}},
PusheeTxn: txn.TxnMeta,
PushType: typ,
}
b := &client.Batch{}
b.AddRawRequest(pushArgs)
if err := db.Run(b); err != nil {
log.Warningf(context.TODO(), "push of txn %s failed: %s", txn, err)
return
}
br := b.RawResponse()
// Update the supplied txn on successful push.
*txn = br.Responses[0].GetInner().(*roachpb.PushTxnResponse).PusheeTxn
}