本文整理汇总了Golang中github.com/cockroachdb/cockroach/proto.RequestHeader.User方法的典型用法代码示例。如果您正苦于以下问题:Golang RequestHeader.User方法的具体用法?Golang RequestHeader.User怎么用?Golang RequestHeader.User使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/proto.RequestHeader
的用法示例。
在下文中一共展示了RequestHeader.User方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateForBatch
// updateForBatch updates the first argument (the header of a request contained
// in a batch) from the second one (the batch header), returning an error when
// inconsistencies are found.
// It is checked that the individual call does not have a User, UserPriority
// or Txn set that differs from the batch's.
func updateForBatch(aHeader *proto.RequestHeader, bHeader proto.RequestHeader) error {
// Disallow transaction, user and priority on individual calls, unless
// equal.
if aHeader.User != "" && aHeader.User != bHeader.User {
return util.Error("conflicting user on call in batch")
}
if aPrio := aHeader.GetUserPriority(); aPrio != proto.Default_RequestHeader_UserPriority && aPrio != bHeader.GetUserPriority() {
return util.Error("conflicting user priority on call in batch")
}
if aHeader.Txn != nil && !aHeader.Txn.Equal(bHeader.Txn) {
return util.Error("conflicting transaction in transactional batch")
}
aHeader.User = bHeader.User
aHeader.UserPriority = bHeader.UserPriority
aHeader.Txn = bHeader.Txn
return nil
}