frostfs-node/pkg/services/object/put/local.go
Leonard Lyubich 1c30414a6c [#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes:
 * avoid package-colliding variable naming
 * avoid using pointers to IDs where unnecessary
 * avoid using `idSDK` import alias pattern
 * use `EncodeToString` for protocol string calculation and `String` for
  printing

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-06-01 17:41:45 +03:00

39 lines
850 B
Go

package putsvc
import (
"fmt"
"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 ObjectStorage
obj *object.Object
}
func (t *localTarget) WriteHeader(obj *object.Object) error {
t.obj = obj
return nil
}
func (t *localTarget) Close() (*transformer.AccessIdentifiers, error) {
if err := t.storage.Put(t.obj); err != nil {
return nil, fmt.Errorf("(%T) could not put object to local storage: %w", t, err)
}
id, _ := t.obj.ID()
return new(transformer.AccessIdentifiers).
WithSelfID(id), nil
}