From d90f53d311e6de79785bb94819b2eed9bd0c3372 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 Aug 2020 18:45:36 +0300 Subject: [PATCH] [#13] neofs-node: Implement Object.Put executor Signed-off-by: Leonard Lyubich --- cmd/neofs-node/object.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index a6f6c9149..d0b53986e 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "io" "github.com/nspcc-dev/neofs-api-go/v2/object" @@ -20,9 +21,9 @@ type simpleGetBodyStreamer struct { count int } -type objectExecutor struct { - count int -} +type simplePutBodyStreamer struct{} + +type objectExecutor struct{} func (s *simpleGetBodyStreamer) Recv() (*object.GetResponseBody, error) { body := new(object.GetResponseBody) @@ -53,8 +54,24 @@ func (*objectExecutor) Get(context.Context, *object.GetRequestBody) (objectServi return new(simpleGetBodyStreamer), nil } -func (*objectExecutor) Put(context.Context) (object.PutObjectStreamer, error) { - panic("implement me") +func (s *simplePutBodyStreamer) Send(body *object.PutRequestBody) error { + fmt.Printf("object part received %T\n", body.GetObjectPart()) + return nil +} + +func (s *simplePutBodyStreamer) CloseAndRecv() (*object.PutResponseBody, error) { + body := new(object.PutResponseBody) + oid := new(refs.ObjectID) + + body.SetObjectID(oid) + + oid.SetValue([]byte{6, 7, 8}) + + return body, nil +} + +func (*objectExecutor) Put(context.Context) (objectService.PutObjectBodyStreamer, error) { + return new(simplePutBodyStreamer), nil } func (*objectExecutor) Head(context.Context, *object.HeadRequestBody) (*object.HeadResponseBody, error) {