From 88c1584e6ad47971ed90b96bc21211a0e286fc26 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 30 Nov 2020 17:30:49 +0300 Subject: [PATCH] [#220] shard: Implement Open/Init/Close methods Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/shard/control.go | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pkg/local_object_storage/shard/control.go diff --git a/pkg/local_object_storage/shard/control.go b/pkg/local_object_storage/shard/control.go new file mode 100644 index 000000000..0fc7e683e --- /dev/null +++ b/pkg/local_object_storage/shard/control.go @@ -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 +}