本文整理汇总了Golang中github.com/chop-dbhi/origins/storage.Tx.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang Tx.Get方法的具体用法?Golang Tx.Get怎么用?Golang Tx.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/chop-dbhi/origins/storage.Tx
的用法示例。
在下文中一共展示了Tx.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetLog
func GetLog(e storage.Tx, domain, name string) (*Log, error) {
var (
bytes []byte
err error
key string
)
key = fmt.Sprintf(logKey, name)
if bytes, err = e.Get(domain, key); err != nil {
return nil, err
}
if bytes == nil {
return nil, nil
}
log := Log{
Domain: domain,
Name: name,
}
if err = unmarshalLog(bytes, &log); err != nil {
return nil, err
}
return &log, nil
}
示例2: GetSegment
// GetSegment returns a segment from storage.
func GetSegment(e storage.Tx, domain string, id *uuid.UUID) (*Segment, error) {
var (
bytes []byte
err error
key string
)
key = fmt.Sprintf(segmentKey, id)
if bytes, err = e.Get(domain, key); err != nil {
return nil, err
}
if bytes == nil {
return nil, nil
}
seg := Segment{
UUID: id,
Domain: domain,
}
if err = unmarshalSegment(bytes, &seg); err != nil {
return nil, err
}
return &seg, nil
}
示例3: GetBlock
// GetBlock returns a block from storage. The lookup requires the domain, ID of the segment
// the block is contained in, the index of the block in the segment, and the transaction
// that processed the segment.
func GetBlock(e storage.Tx, domain string, id *uuid.UUID, idx int) ([]byte, error) {
var key string
key = fmt.Sprintf(blockKey, id, idx)
return e.Get(domain, key)
}