[#13] neofs-node: Use signing Object service in app

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-25 16:37:10 +03:00 committed by Alex Vanin
parent 276ec2e1e0
commit eb874092b5
3 changed files with 56 additions and 13 deletions

View file

@ -3,10 +3,12 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"io"
"net" "net"
containerGRPC "github.com/nspcc-dev/neofs-api-go/v2/container" 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" "github.com/pkg/errors"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@ -43,31 +45,57 @@ func (s *containerSvc) GetExtendedACL(context.Context, *containerGRPC.GetExtende
return nil, unimplementedErr("Container", "GetExtendedACL") 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") 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") 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") return nil, unimplementedErr("Object", "Put")
} }
func (s *objectSvc) Search(context.Context, *objectGRPC.SearchRequest) (objectGRPC.SearchObjectStreamer, error) { type simpleSearchStreamer struct {
return nil, unimplementedErr("Object", "Search") 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") 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") 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") return nil, unimplementedErr("Object", "GetRangeHash")
} }

View file

@ -4,8 +4,6 @@ import (
"fmt" "fmt"
"log" "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" "github.com/nspcc-dev/neofs-node/pkg/util/grace"
) )
@ -35,8 +33,7 @@ func init_(c *cfg) {
initAccountingService(c) initAccountingService(c)
initContainerService(c) initContainerService(c)
initSessionService(c) initSessionService(c)
initObjectService(c)
object.RegisterObjectServiceServer(c.cfgGRPC.server, objectGRPC.New(new(objectSvc)))
} }
func bootUp(c *cfg) { func bootUp(c *cfg) {

18
cmd/neofs-node/object.go Normal file
View file

@ -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),
),
),
)
}