Some checks failed
DCO action / DCO (pull_request) Successful in 1m39s
Build / Build Components (1.20) (pull_request) Failing after 1m54s
Build / Build Components (1.21) (pull_request) Successful in 2m28s
Tests and linters / Tests (1.20) (pull_request) Failing after 2m43s
Vulncheck / Vulncheck (pull_request) Failing after 2m56s
Tests and linters / Lint (pull_request) Failing after 3m45s
Tests and linters / Staticcheck (pull_request) Failing after 4m4s
Tests and linters / Tests (1.21) (pull_request) Failing after 9m11s
Tests and linters / Tests with -race (pull_request) Failing after 9m26s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
42 lines
753 B
Go
42 lines
753 B
Go
package shard
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
)
|
|
|
|
type ContainerSizePrm struct {
|
|
cnr cid.ID
|
|
}
|
|
|
|
type ContainerSizeRes struct {
|
|
size uint64
|
|
}
|
|
|
|
func (p *ContainerSizePrm) SetContainerID(cnr cid.ID) {
|
|
p.cnr = cnr
|
|
}
|
|
|
|
func (r ContainerSizeRes) Size() uint64 {
|
|
return r.size
|
|
}
|
|
|
|
func (s *Shard) ContainerSize(prm ContainerSizePrm) (ContainerSizeRes, error) {
|
|
s.m.RLock()
|
|
defer s.m.RUnlock()
|
|
|
|
if s.info.Mode.NoMetabase() {
|
|
return ContainerSizeRes{}, ErrDegradedMode
|
|
}
|
|
|
|
size, err := s.metaBase.ContainerSize(context.Background(), prm.cnr)
|
|
if err != nil {
|
|
return ContainerSizeRes{}, fmt.Errorf("could not get container size: %w", err)
|
|
}
|
|
|
|
return ContainerSizeRes{
|
|
size: size,
|
|
}, nil
|
|
}
|