In the near future the garbage collector will delete expired tombstones and graves separately. So, all graves should have expiration epochs. Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
37 lines
826 B
Go
37 lines
826 B
Go
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
|
|
}
|