diff --git a/pkg/local_object_storage/engine/container.go b/pkg/local_object_storage/engine/container.go index 0ad977679c..7391e5078f 100644 --- a/pkg/local_object_storage/engine/container.go +++ b/pkg/local_object_storage/engine/container.go @@ -40,7 +40,7 @@ func (r *ListContainersRes) Containers() []*cid.ID { // // Returns empty result if executions are blocked (see BlockExecution). func (e *StorageEngine) ContainerSize(prm *ContainerSizePrm) (res *ContainerSizeRes) { - err := e.exec(func() error { + err := e.execIfNotBlocked(func() error { res = e.containerSize(prm) return nil }) @@ -92,7 +92,7 @@ func (e *StorageEngine) containerSize(prm *ContainerSizePrm) *ContainerSizeRes { // // Returns empty result if executions are blocked (see BlockExecution). func (e *StorageEngine) ListContainers(_ *ListContainersPrm) (res *ListContainersRes) { - err := e.exec(func() error { + err := e.execIfNotBlocked(func() error { res = e.listContainers() return nil }) diff --git a/pkg/local_object_storage/engine/control.go b/pkg/local_object_storage/engine/control.go index 3b7a828cf5..3e3f44184f 100644 --- a/pkg/local_object_storage/engine/control.go +++ b/pkg/local_object_storage/engine/control.go @@ -44,7 +44,7 @@ var errClosed = errors.New("storage engine is closed") // Close releases all StorageEngine's components. Waits for all data-related operations to complete. // After the call, all the next ones will fail until the ResumeExecution call. // -// Еhe method is supposed to be called when the application exits. +// The method is supposed to be called when the application exits. func (e *StorageEngine) Close() error { return e.setBlockExecErr(errClosed) } @@ -73,7 +73,7 @@ func (e *StorageEngine) close() error { // executes op if execution is not blocked, otherwise returns blocking error. // // Can be called concurrently with setBlockExecErr. -func (e *StorageEngine) exec(op func() error) error { +func (e *StorageEngine) execIfNotBlocked(op func() error) error { e.blockExec.mtx.RLock() defer e.blockExec.mtx.RUnlock() @@ -110,7 +110,7 @@ func (e *StorageEngine) setBlockExecErr(err error) error { return nil } -// BlockExecution block blocks the execution of any data-related operation. All blocked ops will return err. +// BlockExecution blocks the execution of any data-related operation. All blocked ops will return err. // To resume the execution, use ResumeExecution method. // // Сan be called regardless of the fact of the previous blocking. If execution wasn't blocked, releases all resources diff --git a/pkg/local_object_storage/engine/delete.go b/pkg/local_object_storage/engine/delete.go index 2f645cbaca..aa3423b1b2 100644 --- a/pkg/local_object_storage/engine/delete.go +++ b/pkg/local_object_storage/engine/delete.go @@ -29,7 +29,7 @@ func (p *DeletePrm) WithAddresses(addr ...*objectSDK.Address) *DeletePrm { // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) Delete(prm *DeletePrm) (res *DeleteRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e.delete(prm) return err }) diff --git a/pkg/local_object_storage/engine/get.go b/pkg/local_object_storage/engine/get.go index 3d41fea6e3..e37eb2e9f7 100644 --- a/pkg/local_object_storage/engine/get.go +++ b/pkg/local_object_storage/engine/get.go @@ -45,7 +45,7 @@ func (r *GetRes) Object() *object.Object { // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) Get(prm *GetPrm) (res *GetRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e.get(prm) return err }) diff --git a/pkg/local_object_storage/engine/head.go b/pkg/local_object_storage/engine/head.go index 5449a7b71e..0e3bf38e85 100644 --- a/pkg/local_object_storage/engine/head.go +++ b/pkg/local_object_storage/engine/head.go @@ -60,7 +60,7 @@ func (r *HeadRes) Header() *object.Object { // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) Head(prm *HeadPrm) (res *HeadRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e.head(prm) return err }) diff --git a/pkg/local_object_storage/engine/inhume.go b/pkg/local_object_storage/engine/inhume.go index b1cb62703a..a16d84c021 100644 --- a/pkg/local_object_storage/engine/inhume.go +++ b/pkg/local_object_storage/engine/inhume.go @@ -52,7 +52,7 @@ var errInhumeFailure = errors.New("inhume operation failed") // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) Inhume(prm *InhumePrm) (res *InhumeRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e.inhume(prm) return err }) diff --git a/pkg/local_object_storage/engine/put.go b/pkg/local_object_storage/engine/put.go index c6da03e5bf..cda62b93a2 100644 --- a/pkg/local_object_storage/engine/put.go +++ b/pkg/local_object_storage/engine/put.go @@ -36,7 +36,7 @@ func (p *PutPrm) WithObject(obj *object.Object) *PutPrm { // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) Put(prm *PutPrm) (res *PutRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e.put(prm) return err }) diff --git a/pkg/local_object_storage/engine/range.go b/pkg/local_object_storage/engine/range.go index 97ffe3a1cc..8be165627e 100644 --- a/pkg/local_object_storage/engine/range.go +++ b/pkg/local_object_storage/engine/range.go @@ -63,7 +63,7 @@ func (r *RngRes) Object() *object.Object { // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) GetRange(prm *RngPrm) (res *RngRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e.getRange(prm) return err }) diff --git a/pkg/local_object_storage/engine/select.go b/pkg/local_object_storage/engine/select.go index 5a9634558b..c221cfe7d5 100644 --- a/pkg/local_object_storage/engine/select.go +++ b/pkg/local_object_storage/engine/select.go @@ -50,7 +50,7 @@ func (r *SelectRes) AddressList() []*object.Address { // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) Select(prm *SelectPrm) (res *SelectRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e._select(prm) return err }) @@ -111,7 +111,7 @@ func (e *StorageEngine) _select(prm *SelectPrm) (*SelectRes, error) { // // Returns an error if executions are blocked (see BlockExecution). func (e *StorageEngine) List(limit uint64) (res *SelectRes, err error) { - err = e.exec(func() error { + err = e.execIfNotBlocked(func() error { res, err = e.list(limit) return err })