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"
|
"path"
|
||||||
|
|
||||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PutPrm groups the parameters of Put operation.
|
// PutPrm groups the parameters of Put operation.
|
||||||
type PutPrm struct {
|
type PutPrm struct {
|
||||||
obj *object.Object
|
rwObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutRes groups resulting values of Put operation.
|
// PutRes groups resulting values of Put operation.
|
||||||
type PutRes struct{}
|
type PutRes struct {
|
||||||
|
roBlobovniczaID
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put saves the object in BLOB storage.
|
// 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
|
// Returns any error encountered that
|
||||||
// did not allow to completely save the object.
|
// did not allow to completely save the object.
|
||||||
func (b *BlobStor) Put(prm *PutPrm) (*PutRes, error) {
|
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
|
// try to put to WriteCache
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
|
||||||
|
// form Put parameters
|
||||||
|
putPrm := new(blobstor.PutPrm)
|
||||||
|
putPrm.SetObject(prm.obj)
|
||||||
|
|
||||||
// put to BlobStor
|
// put to BlobStor
|
||||||
if _, err := s.blobStor.Put(
|
if _, err := s.blobStor.Put(putPrm); err != nil {
|
||||||
new(blobstor.PutPrm).
|
|
||||||
WithObject(prm.obj),
|
|
||||||
); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not put object to BLOB storage")
|
return nil, errors.Wrap(err, "could not put object to BLOB storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue