[#11] Use accounting service executor in neofs-node app

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-22 17:36:34 +03:00 committed by Alex Vanin
parent 7cc1a2a85a
commit 3ae7f7e914

View file

@ -11,8 +11,8 @@ import (
container "github.com/nspcc-dev/neofs-api-go/v2/container/grpc" container "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object" objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object"
object "github.com/nspcc-dev/neofs-api-go/v2/object/grpc" object "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
sessionGRPC "github.com/nspcc-dev/neofs-api-go/v2/session" "github.com/nspcc-dev/neofs-api-go/v2/session"
session "github.com/nspcc-dev/neofs-api-go/v2/session/grpc" sessionGRPC "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
accountingTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/accounting/grpc" accountingTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/accounting/grpc"
containerTransport "github.com/nspcc-dev/neofs-node/pkg/network/transport/container/grpc" containerTransport "github.com/nspcc-dev/neofs-node/pkg/network/transport/container/grpc"
objectTransport "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc" objectTransport "github.com/nspcc-dev/neofs-node/pkg/network/transport/object/grpc"
@ -22,7 +22,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
type accountingSvc struct{} type accountingSvcExec struct{}
type sessionSvc struct{} type sessionSvc struct{}
@ -34,11 +34,11 @@ func unimplementedErr(srv, call string) error {
return errors.Errorf("unimplemented API service call %s.%s", srv, call) return errors.Errorf("unimplemented API service call %s.%s", srv, call)
} }
func (s *accountingSvc) Balance(context.Context, *accounting.BalanceRequest) (*accounting.BalanceResponse, error) { func (s *accountingSvcExec) Balance(context.Context, *accounting.BalanceRequestBody) (*accounting.BalanceResponseBody, error) {
return new(accounting.BalanceResponse), nil return new(accounting.BalanceResponseBody), nil
} }
func (s *sessionSvc) Create(context.Context, *sessionGRPC.CreateRequest) (*sessionGRPC.CreateResponse, error) { func (s *sessionSvc) Create(context.Context, *session.CreateRequest) (*session.CreateResponse, error) {
return nil, unimplementedErr("Session", "Create") return nil, unimplementedErr("Session", "Create")
} }
@ -100,11 +100,22 @@ func serveGRPC(c *cfg) {
srv := grpc.NewServer() srv := grpc.NewServer()
metaHdr := new(session.ResponseMetaHeader)
xHdr := new(session.XHeader)
xHdr.SetKey("test X-Header key")
xHdr.SetValue("test X-Header value")
metaHdr.SetXHeaders([]*session.XHeader{xHdr})
accountingGRPC.RegisterAccountingServiceServer(srv, accountingGRPC.RegisterAccountingServiceServer(srv,
accountingTransportGRPC.New(accountingService.NewSignService(c.key, new(accountingSvc))), accountingTransportGRPC.New(
accountingService.NewSignService(
c.key,
accountingService.NewExecutionService(new(accountingSvcExec), metaHdr),
),
),
) )
container.RegisterContainerServiceServer(srv, containerTransport.New(new(containerSvc))) container.RegisterContainerServiceServer(srv, containerTransport.New(new(containerSvc)))
session.RegisterSessionServiceServer(srv, sessionTransport.New(new(sessionSvc))) sessionGRPC.RegisterSessionServiceServer(srv, sessionTransport.New(new(sessionSvc)))
object.RegisterObjectServiceServer(srv, objectTransport.New(new(objectSvc))) object.RegisterObjectServiceServer(srv, objectTransport.New(new(objectSvc)))
go func() { go func() {