frostfs-api-go-pogpp/object/sg.go

44 lines
1 KiB
Go
Raw Normal View History

2019-11-18 13:34:06 +00:00
package object
import (
"sort"
2019-12-02 14:56:06 +00:00
2020-03-31 07:05:26 +00:00
"github.com/nspcc-dev/neofs-api-go/refs"
"github.com/nspcc-dev/neofs-api-go/storagegroup"
2019-11-18 13:34:06 +00:00
)
// Here are defined getter functions for objects that contain storage group
// information.
2019-12-02 14:56:06 +00:00
var _ storagegroup.Provider = (*Object)(nil)
2019-11-18 13:34:06 +00:00
// Group returns slice of object ids that are part of a storage group.
2019-12-02 14:56:06 +00:00
func (m *Object) Group() []refs.ObjectID {
2019-11-18 13:34:06 +00:00
sgLinks := m.Links(Link_StorageGroup)
2019-12-02 14:56:06 +00:00
sort.Sort(storagegroup.IDList(sgLinks))
2019-11-18 13:34:06 +00:00
return sgLinks
}
// Zones returns validation zones of storage group.
2019-12-02 14:56:06 +00:00
func (m *Object) Zones() []storagegroup.ZoneInfo {
2019-11-18 13:34:06 +00:00
sgInfo, err := m.StorageGroup()
if err != nil {
return nil
}
2019-12-02 14:56:06 +00:00
return []storagegroup.ZoneInfo{
2019-11-18 13:34:06 +00:00
{
Hash: sgInfo.ValidationHash,
Size: sgInfo.ValidationDataSize,
},
}
}
// IDInfo returns meta information about storage group.
2019-12-02 14:56:06 +00:00
func (m *Object) IDInfo() *storagegroup.IdentificationInfo {
return &storagegroup.IdentificationInfo{
2019-11-18 13:34:06 +00:00
SGID: m.SystemHeader.ID,
CID: m.SystemHeader.CID,
OwnerID: m.SystemHeader.OwnerID,
}
}