From 5caabf4208f98e6cda01288e1b624997026c5bd6 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 Aug 2020 18:08:58 +0300 Subject: [PATCH] [#13] neofs-node: Implement Object.Get executor Signed-off-by: Leonard Lyubich --- cmd/neofs-node/object.go | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 0de7ef92..a6f6c914 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -16,12 +16,41 @@ type simpleSearchBodyStreamer struct { count int } +type simpleGetBodyStreamer struct { + count int +} + type objectExecutor struct { count int } +func (s *simpleGetBodyStreamer) Recv() (*object.GetResponseBody, error) { + body := new(object.GetResponseBody) + + id := new(refs.ObjectID) + id.SetValue([]byte{1, 2, 3}) + + if s.count == 0 { + in := new(object.GetObjectPartInit) + in.SetObjectID(id) + + body.SetObjectPart(in) + } else if s.count == 1 { + c := new(object.GetObjectPartChunk) + c.SetChunk([]byte{8, 8, 0, 0, 5, 5, 5, 3, 5, 3, 5}) + + body.SetObjectPart(c) + } else { + return nil, io.EOF + } + + s.count++ + + return body, nil +} + func (*objectExecutor) Get(context.Context, *object.GetRequestBody) (objectService.GetObjectBodyStreamer, error) { - panic("implement me") + return new(simpleGetBodyStreamer), nil } func (*objectExecutor) Put(context.Context) (object.PutObjectStreamer, error) {