frostfs-node/pkg/network/transport/session/grpc/service.go
Airat Arifullin 9b13a18aac [#1479] go.mod: Bump frostfs-sdk-go version
* Update version within go.mod;
* Fix deprecated frostfs-api-go/v2 package and use frostfs-sdk-go/api
  instead.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-11-08 10:43:19 +03:00

37 lines
1,004 B
Go

package session
import (
"context"
sessionsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/session"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
sessionGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session/grpc"
)
// Server wraps FrostFS 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
}