diff --git a/cmd/neofs-node/grpc.go b/cmd/neofs-node/grpc.go index b5f0436f31..68078f200b 100644 --- a/cmd/neofs-node/grpc.go +++ b/cmd/neofs-node/grpc.go @@ -3,10 +3,12 @@ package main import ( "context" "fmt" + "io" "net" containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container" - objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object" + "github.com/nspcc-dev/neofs-api-go/v2/object" + "github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/pkg/errors" "google.golang.org/grpc" ) @@ -43,31 +45,57 @@ func (s *containerSvc) GetExtendedACL(context.Context, *containerGRPC.GetExtende return nil, unimplementedErr("Container", "GetExtendedACL") } -func (s *objectSvc) Get(context.Context, *objectGRPC.GetRequest) (objectGRPC.GetObjectStreamer, error) { +func (s *objectSvc) Get(context.Context, *object.GetRequest) (object.GetObjectStreamer, error) { return nil, unimplementedErr("Object", "Get") } -func (s *objectSvc) Put(context.Context) (objectGRPC.PutObjectStreamer, error) { +func (s *objectSvc) Put(context.Context) (object.PutObjectStreamer, error) { return nil, unimplementedErr("Object", "Put") } -func (s *objectSvc) Head(context.Context, *objectGRPC.HeadRequest) (*objectGRPC.HeadResponse, error) { +func (s *objectSvc) Head(context.Context, *object.HeadRequest) (*object.HeadResponse, error) { return nil, unimplementedErr("Object", "Put") } -func (s *objectSvc) Search(context.Context, *objectGRPC.SearchRequest) (objectGRPC.SearchObjectStreamer, error) { - return nil, unimplementedErr("Object", "Search") +type simpleSearchStreamer struct { + count int } -func (s *objectSvc) Delete(context.Context, *objectGRPC.DeleteRequest) (*objectGRPC.DeleteResponse, error) { +func (s *simpleSearchStreamer) Recv() (*object.SearchResponse, error) { + resp := new(object.SearchResponse) + + body := new(object.SearchResponseBody) + resp.SetBody(body) + + id := new(refs.ObjectID) + body.SetIDList([]*refs.ObjectID{id}) + + if s.count == 0 { + id.SetValue([]byte{1}) + } else if s.count == 1 { + id.SetValue([]byte{2}) + } else { + return nil, io.EOF + } + + s.count++ + + return resp, nil +} + +func (s *objectSvc) Search(context.Context, *object.SearchRequest) (object.SearchObjectStreamer, error) { + return new(simpleSearchStreamer), nil +} + +func (s *objectSvc) Delete(context.Context, *object.DeleteRequest) (*object.DeleteResponse, error) { return nil, unimplementedErr("Object", "Delete") } -func (s *objectSvc) GetRange(context.Context, *objectGRPC.GetRangeRequest) (objectGRPC.GetRangeObjectStreamer, error) { +func (s *objectSvc) GetRange(context.Context, *object.GetRangeRequest) (object.GetRangeObjectStreamer, error) { return nil, unimplementedErr("Object", "GetRange") } -func (s *objectSvc) GetRangeHash(context.Context, *objectGRPC.GetRangeHashRequest) (*objectGRPC.GetRangeHashResponse, error) { +func (s *objectSvc) GetRangeHash(context.Context, *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) { return nil, unimplementedErr("Object", "GetRangeHash") } diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index 1c77a466b0..400ab91c29 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -4,8 +4,6 @@ import ( "fmt" "log" - object "github.com/nspcc-dev/neofs-api-go/v2/object/grpc" - objectGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc" "github.com/nspcc-dev/neofs-node/pkg/util/grace" ) @@ -35,8 +33,7 @@ func init_(c *cfg) { initAccountingService(c) initContainerService(c) initSessionService(c) - - object.RegisterObjectServiceServer(c.cfgGRPC.server, objectGRPC.New(new(objectSvc))) + initObjectService(c) } func bootUp(c *cfg) { diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go new file mode 100644 index 0000000000..472fc005c8 --- /dev/null +++ b/cmd/neofs-node/object.go @@ -0,0 +1,18 @@ +package main + +import ( + objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object/grpc" + objectTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc" + objectService "github.com/nspcc-dev/neofs-node/pkg/services/object" +) + +func initObjectService(c *cfg) { + objectGRPC.RegisterObjectServiceServer(c.cfgGRPC.server, + objectTransportGRPC.New( + objectService.NewSignService( + c.key, + new(objectSvc), + ), + ), + ) +}