frostfs-node/pkg/network/transport/session/grpc/service.go
Evgenii Stratonikov 050a4bb2b0 [] *: link TODOs to corresponding issues
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-02-11 12:58:59 +03:00

37 lines
967 B
Go

package session
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/session"
sessionGRPC "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
sessionsvc "github.com/nspcc-dev/neofs-node/pkg/services/session"
)
// Server wraps NeoFS API Session service and
// provides gRPC Session service server interface.
type Server struct {
srv sessionsvc.Server
}
// New creates, initializes and returns Server instance.
func New(c sessionsvc.Server) *Server {
return &Server{
srv: c,
}
}
// Create converts gRPC CreateRequest message and passes it to internal Session service.
func (s *Server) Create(ctx context.Context, req *sessionGRPC.CreateRequest) (*sessionGRPC.CreateResponse, error) {
createReq := new(session.CreateRequest)
if err := createReq.FromGRPCMessage(req); err != nil {
return nil, err
}
resp, err := s.srv.Create(ctx, createReq)
if err != nil {
return nil, err
}
return resp.ToGRPCMessage().(*sessionGRPC.CreateResponse), nil
}