forked from TrueCloudLab/frostfs-node
590745204c
All parameters and resulting values of all metabase operations are structured in new types. The most popular scenarios for using operations are moved to auxiliary functions. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
37 lines
826 B
Go
37 lines
826 B
Go
package shard
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (s *Shard) List() (*SelectRes, error) {
|
|
lst, err := s.metaBase.Containers()
|
|
if err != nil {
|
|
return nil, fmt.Errorf("can't list stored containers: %w", err)
|
|
}
|
|
|
|
res := new(SelectRes)
|
|
filters := object.NewSearchFilters()
|
|
|
|
for i := range lst {
|
|
filters = filters[:0]
|
|
filters.AddObjectContainerIDFilter(object.MatchStringEqual, lst[i])
|
|
|
|
ids, err := meta.Select(s.metaBase, filters) // consider making List in metabase
|
|
if err != nil {
|
|
s.log.Debug("can't select all objects",
|
|
zap.Stringer("cid", lst[i]),
|
|
zap.String("error", err.Error()))
|
|
|
|
continue
|
|
}
|
|
|
|
res.addrList = append(res.addrList, ids...)
|
|
}
|
|
|
|
return res, nil
|
|
}
|