forked from TrueCloudLab/frostfs-node
1c30414a6c
Core changes: * avoid package-colliding variable naming * avoid using pointers to IDs where unnecessary * avoid using `idSDK` import alias pattern * use `EncodeToString` for protocol string calculation and `String` for printing Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
47 lines
813 B
Go
47 lines
813 B
Go
package shard
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
)
|
|
|
|
type ContainerSizePrm struct {
|
|
cnr cid.ID
|
|
}
|
|
|
|
type ContainerSizeRes struct {
|
|
size uint64
|
|
}
|
|
|
|
func (p *ContainerSizePrm) WithContainerID(cnr cid.ID) *ContainerSizePrm {
|
|
if p != nil {
|
|
p.cnr = cnr
|
|
}
|
|
|
|
return p
|
|
}
|
|
|
|
func (r *ContainerSizeRes) Size() uint64 {
|
|
return r.size
|
|
}
|
|
|
|
func (s *Shard) ContainerSize(prm *ContainerSizePrm) (*ContainerSizeRes, error) {
|
|
size, err := s.metaBase.ContainerSize(prm.cnr)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not get container size: %w", err)
|
|
}
|
|
|
|
return &ContainerSizeRes{
|
|
size: size,
|
|
}, nil
|
|
}
|
|
|
|
func ContainerSize(s *Shard, cnr cid.ID) (uint64, error) {
|
|
res, err := s.ContainerSize(&ContainerSizePrm{cnr: cnr})
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
return res.Size(), nil
|
|
}
|