38 lines
763 B
Go
38 lines
763 B
Go
package blobovniczatree
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
|
)
|
|
|
|
func (b *Blobovniczas) ObjectsCount(ctx context.Context) (uint64, error) {
|
|
var (
|
|
success bool
|
|
startedAt = time.Now()
|
|
)
|
|
defer func() {
|
|
b.metrics.ObjectsCount(time.Since(startedAt), success)
|
|
}()
|
|
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "Blobovniczas.ObjectsCount")
|
|
defer span.End()
|
|
|
|
var result uint64
|
|
err := b.iterateExistingDBPaths(ctx, func(p string) (bool, error) {
|
|
shDB := b.getBlobovniczaWithoutCaching(p)
|
|
blz, err := shDB.Open(ctx)
|
|
if err != nil {
|
|
return true, err
|
|
}
|
|
defer shDB.Close(ctx)
|
|
|
|
result += blz.ObjectsCount()
|
|
return false, nil
|
|
})
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result, nil
|
|
}
|