[#1559] local_object_storage: Provide readOnly flag to Open

We should be able to reopen storage in readonly in runtime.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-06-28 16:42:50 +03:00 committed by fyrchik
parent e38b0aa4ba
commit 1e786233bf
20 changed files with 70 additions and 49 deletions

View file

@ -14,20 +14,20 @@ import (
// Open opens all Shard's components.
func (s *Shard) Open() error {
components := []interface{ Open() error }{
components := []interface{ Open(bool) error }{
s.blobStor, s.metaBase,
}
if s.pilorama != nil {
components = append(components, s.pilorama)
}
if s.hasWriteCache() {
components = append(components, s.writeCache)
}
if s.pilorama != nil {
components = append(components, s.pilorama)
}
for _, component := range components {
if err := component.Open(); err != nil {
if err := component.Open(false); err != nil {
return fmt.Errorf("could not open %T: %w", component, err)
}
}
@ -48,14 +48,14 @@ func (s *Shard) Init() error {
s.blobStor.Init, fMetabase,
}
if s.pilorama != nil {
components = append(components, s.pilorama.Init)
}
if s.hasWriteCache() {
components = append(components, s.writeCache.Init)
}
if s.pilorama != nil {
components = append(components, s.pilorama.Init)
}
for _, component := range components {
if err := component(); err != nil {
return fmt.Errorf("could not initialize %T: %w", component, err)
@ -162,14 +162,14 @@ func (s *Shard) refillMetabase() error {
func (s *Shard) Close() error {
components := []interface{ Close() error }{}
if s.hasWriteCache() {
components = append(components, s.writeCache)
}
if s.pilorama != nil {
components = append(components, s.pilorama)
}
if s.hasWriteCache() {
components = append(components, s.writeCache)
}
components = append(components, s.blobStor, s.metaBase)
for _, component := range components {