frostfs-node/pkg/local_object_storage/shard/count.go
Dmitrii Stepanov d8c9159853 [#1099] metabase: Change engine to badger
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2024-07-04 11:13:49 +03:00

31 lines
677 B
Go

package shard
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
// LogicalObjectsCount returns logical objects count.
func (s *Shard) LogicalObjectsCount(ctx context.Context) (uint64, error) {
_, span := tracing.StartSpanFromContext(ctx, "Shard.LogicalObjectsCount",
trace.WithAttributes(
attribute.String("shard_id", s.ID().String()),
))
defer span.End()
s.m.RLock()
defer s.m.RUnlock()
if s.GetMode().NoMetabase() {
return 0, ErrDegradedMode
}
cc, err := s.metaBase.ObjectCounters(ctx)
if err != nil {
return 0, err
}
return cc.Logic, nil
}