forked from TrueCloudLab/frostfs-node
[#211] blobstor: Refactor Put operation
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7afcde659d
commit
b605ea3678
2 changed files with 12 additions and 17 deletions
|
@ -6,31 +6,25 @@ import (
|
|||
"path"
|
||||
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// PutPrm groups the parameters of Put operation.
|
||||
type PutPrm struct {
|
||||
obj *object.Object
|
||||
rwObject
|
||||
}
|
||||
|
||||
// PutRes groups resulting values of Put operation.
|
||||
type PutRes struct{}
|
||||
|
||||
// WithObject is a Put option to set object to save.
|
||||
//
|
||||
// Option is required.
|
||||
func (p *PutPrm) WithObject(obj *object.Object) *PutPrm {
|
||||
if p != nil {
|
||||
p.obj = obj
|
||||
}
|
||||
|
||||
return p
|
||||
type PutRes struct {
|
||||
roBlobovniczaID
|
||||
}
|
||||
|
||||
// Put saves the object in BLOB storage.
|
||||
//
|
||||
// If object is "big", BlobStor saves the object in shallow dir.
|
||||
// Otherwise, BlobStor saves the object in blobonicza. In this
|
||||
// case the identifier of blobovnicza is returned.
|
||||
//
|
||||
// Returns any error encountered that
|
||||
// did not allow to completely save the object.
|
||||
func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
|
||||
|
|
|
@ -39,11 +39,12 @@ func (s *Shard) Put(prm *PutPrm) (*PutRes, error) {
|
|||
// try to put to WriteCache
|
||||
// TODO: implement
|
||||
|
||||
// form Put parameters
|
||||
putPrm := new(blobstor.PutPrm)
|
||||
putPrm.SetObject(prm.obj)
|
||||
|
||||
// put to BlobStor
|
||||
if _, err := s.blobStor.Put(
|
||||
new(blobstor.PutPrm).
|
||||
WithObject(prm.obj),
|
||||
); err != nil {
|
||||
if _, err := s.blobStor.Put(putPrm); err != nil {
|
||||
return nil, errors.Wrap(err, "could not put object to BLOB storage")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue