Alex Vanin
20de74a505
Due to source code relocation from GitHub. Signed-off-by: Alex Vanin <a.vanin@yadro.com>
37 lines
1,002 B
Go
37 lines
1,002 B
Go
package session
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
|
sessionGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/grpc"
|
|
sessionsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/session"
|
|
)
|
|
|
|
// 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
|
|
}
|