frostfs-node/pkg/services/metrics/meta.go

34 lines
497 B
Go
Raw Normal View History

package metrics
import (
"sync"
2020-07-24 13:54:03 +00:00
meta2 "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/meta"
)
type metaWrapper struct {
sync.Mutex
2020-07-24 13:54:03 +00:00
iter meta2.Iterator
}
func newMetaWrapper() *metaWrapper {
return &metaWrapper{}
}
2020-07-24 13:54:03 +00:00
func (m *metaWrapper) changeIter(iter meta2.Iterator) {
m.Lock()
m.iter = iter
m.Unlock()
}
2020-07-24 13:54:03 +00:00
func (m *metaWrapper) Iterate(h meta2.IterateFunc) error {
m.Lock()
defer m.Unlock()
if m.iter == nil {
return errEmptyMetaStore
}
return m.iter.Iterate(h)
}