From b605ea3678cf0333d0d0ba375de5911728934696 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 24 Nov 2020 17:24:07 +0300 Subject: [PATCH] [#211] blobstor: Refactor Put operation Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/blobstor/put.go | 20 +++++++------------- pkg/local_object_storage/shard/put.go | 9 +++++---- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/pkg/local_object_storage/blobstor/put.go b/pkg/local_object_storage/blobstor/put.go index 05c52abd..b62858fc 100644 --- a/pkg/local_object_storage/blobstor/put.go +++ b/pkg/local_object_storage/blobstor/put.go @@ -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) { diff --git a/pkg/local_object_storage/shard/put.go b/pkg/local_object_storage/shard/put.go index 29c74f8b..8c941eeb 100644 --- a/pkg/local_object_storage/shard/put.go +++ b/pkg/local_object_storage/shard/put.go @@ -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") }