forked from TrueCloudLab/frostfs-node
[#220] shard: Implement Open/Init/Close methods
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
d30454a572
commit
88c1584e6a
1 changed files with 53 additions and 0 deletions
53
pkg/local_object_storage/shard/control.go
Normal file
53
pkg/local_object_storage/shard/control.go
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
package shard
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Open opens all Shard's components.
|
||||||
|
func (s *Shard) Open() error {
|
||||||
|
for _, component := range []interface {
|
||||||
|
Open() error
|
||||||
|
}{
|
||||||
|
s.blobStor,
|
||||||
|
s.metaBase,
|
||||||
|
} {
|
||||||
|
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 {
|
||||||
|
for _, component := range []interface {
|
||||||
|
Init() error
|
||||||
|
}{
|
||||||
|
s.blobStor,
|
||||||
|
s.metaBase,
|
||||||
|
} {
|
||||||
|
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 {
|
||||||
|
for _, component := range []interface {
|
||||||
|
Close() error
|
||||||
|
}{
|
||||||
|
s.blobStor,
|
||||||
|
s.metaBase,
|
||||||
|
} {
|
||||||
|
if err := component.Close(); err != nil {
|
||||||
|
return errors.Wrapf(err, "could not close %s", component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in a new issue