2020-11-30 17:16:11 +03:00
|
|
|
package blobstor
|
|
|
|
|
2022-06-27 11:36:32 +03:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2020-11-30 17:16:11 +03:00
|
|
|
// Open opens BlobStor.
|
2022-06-28 16:42:50 +03:00
|
|
|
func (b *BlobStor) Open(readOnly bool) error {
|
2020-11-30 17:16:11 +03:00
|
|
|
b.log.Debug("opening...")
|
|
|
|
|
2022-06-28 16:42:50 +03:00
|
|
|
b.blobovniczas.readOnly = readOnly
|
|
|
|
|
2020-11-30 17:16:11 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-06-27 11:36:32 +03:00
|
|
|
// ErrInitBlobovniczas is returned when blobovnicza initialization fails.
|
|
|
|
var ErrInitBlobovniczas = errors.New("failure on blobovnicza initialization stage")
|
|
|
|
|
2020-11-30 17:16:11 +03:00
|
|
|
// Init initializes internal data structures and system resources.
|
|
|
|
//
|
2022-04-21 14:28:05 +03:00
|
|
|
// If BlobStor is already initialized, no action is taken.
|
2022-06-27 11:36:32 +03:00
|
|
|
//
|
|
|
|
// Returns wrapped ErrInitBlobovniczas on blobovnicza tree's initializaiton failure.
|
2020-11-30 17:16:11 +03:00
|
|
|
func (b *BlobStor) Init() error {
|
|
|
|
b.log.Debug("initializing...")
|
|
|
|
|
2022-06-27 11:36:32 +03:00
|
|
|
err := b.blobovniczas.init()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%w: %v", ErrInitBlobovniczas, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2020-11-30 17:16:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Close releases all internal resources of BlobStor.
|
|
|
|
func (b *BlobStor) Close() error {
|
|
|
|
b.log.Debug("closing...")
|
|
|
|
|
|
|
|
return b.blobovniczas.close()
|
|
|
|
}
|