[#1243] node/object: Hide engine behind interface

Do not use engine as explicit dependency in the put service. This allows
wrapping storage engine.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-03-15 22:40:31 +03:00 committed by Alex Vanin
parent a4a29f3442
commit 16543a1904
2 changed files with 12 additions and 6 deletions

View file

@ -3,13 +3,20 @@ package putsvc
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/transformer"
"github.com/nspcc-dev/neofs-sdk-go/object"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
)
// ObjectStorage is an object storage interface.
type ObjectStorage interface {
// Put must save passed object
// and return any appeared error.
Put(o *objectSDK.Object) error
}
type localTarget struct {
storage *engine.StorageEngine
storage ObjectStorage
obj *object.Object
@ -31,7 +38,7 @@ func (t *localTarget) Write(p []byte) (n int, err error) {
}
func (t *localTarget) Close() (*transformer.AccessIdentifiers, error) {
if err := engine.Put(t.storage, t.obj); err != nil {
if err := t.storage.Put(t.obj); err != nil {
return nil, fmt.Errorf("(%T) could not put object to local storage: %w", t, err)
}