frostfs-node/pkg/core/object/object.go

38 lines
826 B
Go
Raw Normal View History

package object
import (
"strconv"
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
)
// AddressOf returns the address of the object.
func AddressOf(obj *objectSDK.Object) oid.Address {
var addr oid.Address
id, ok := obj.ID()
if ok {
addr.SetObject(id)
}
cnr, ok := obj.ContainerID()
if ok {
addr.SetContainer(cnr)
}
return addr
}
// ExpirationEpoch returns the expiration epoch of the object.
func ExpirationEpoch(obj *objectSDK.Object) (epoch uint64, found bool) {
for _, attr := range obj.Attributes() {
if attr.Key() == objectV2.SysAttributeExpEpoch {
epoch, err := strconv.ParseUint(attr.Value(), 10, 64)
return epoch, err == nil
}
}
return
}