frostfs-node/pkg/local_object_storage/shard/control.go
Alex Vanin 1b76458684 [#222] Add writeCache instance to shard
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-11 17:19:37 +03:00

62 lines
1.2 KiB
Go

package shard
import (
"github.com/pkg/errors"
)
// Open opens all Shard's components.
func (s *Shard) Open() error {
components := []interface{ Open() error }{
s.blobStor, s.metaBase,
}
if s.hasWriteCache() {
components = append(components, s.writeCache)
}
for _, component := range components {
if err := component.Open(); err != nil {
return errors.Wrapf(err, "could not open %s", component)
}
}
return nil
}
// Init initializes all Shard's components.
func (s *Shard) Init() error {
components := []interface{ Init() error }{
s.blobStor, s.metaBase,
}
if s.hasWriteCache() {
components = append(components, s.writeCache)
}
for _, component := range components {
if err := component.Init(); err != nil {
return errors.Wrapf(err, "could not initialize %s", component)
}
}
return nil
}
// Close releases all Shard's components.
func (s *Shard) Close() error {
components := []interface{ Close() error }{
s.blobStor, s.metaBase,
}
if s.hasWriteCache() {
components = append(components, s.writeCache)
}
for _, component := range components {
if err := component.Close(); err != nil {
return errors.Wrapf(err, "could not close %s", component)
}
}
return nil
}