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 }
// 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 }
// 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) }