39 lines
755 B
Go
39 lines
755 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)
|
||
|
}()
|
||
|
|
||
|
_, 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()
|
||
|
if err != nil {
|
||
|
return true, err
|
||
|
}
|
||
|
defer shDB.Close()
|
||
|
|
||
|
result += blz.ObjectsCount()
|
||
|
return false, nil
|
||
|
})
|
||
|
if err != nil {
|
||
|
return 0, err
|
||
|
}
|
||
|
return result, nil
|
||
|
}
|