2020-08-24 09:40:04 +00:00
|
|
|
package session
|
2020-08-22 10:18:50 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
sessionsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/session"
|
2024-11-07 14:32:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
|
|
|
|
sessionGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session/grpc"
|
2020-08-22 10:18:50 +00:00
|
|
|
)
|
|
|
|
|
2023-02-05 15:59:38 +00:00
|
|
|
// Server wraps FrostFS API Session service and
|
2020-08-22 10:18:50 +00:00
|
|
|
// provides gRPC Session service server interface.
|
|
|
|
type Server struct {
|
2021-03-15 10:53:08 +00:00
|
|
|
srv sessionsvc.Server
|
2020-08-22 10:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// New creates, initializes and returns Server instance.
|
2021-03-15 10:53:08 +00:00
|
|
|
func New(c sessionsvc.Server) *Server {
|
2020-08-22 10:18:50 +00:00
|
|
|
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) {
|
2021-03-15 10:59:28 +00:00
|
|
|
createReq := new(session.CreateRequest)
|
|
|
|
if err := createReq.FromGRPCMessage(req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := s.srv.Create(ctx, createReq)
|
2020-08-22 10:18:50 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-03-15 10:59:28 +00:00
|
|
|
return resp.ToGRPCMessage().(*sessionGRPC.CreateResponse), nil
|
2020-08-22 10:18:50 +00:00
|
|
|
}
|