frostfs-node/pkg/network/transport/apemanager/grpc/service.go

64 lines
1.7 KiB
Go
Raw Normal View History

package apemanager
import (
"context"
apemanager_svc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/apemanager"
apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/apemanager"
apemanager_grpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/apemanager/grpc"
)
type Server struct {
srv apemanager_svc.Server
}
var _ apemanager_grpc.APEManagerServiceServer = (*Server)(nil)
func New(c apemanager_svc.Server) *Server {
return &Server{
srv: c,
}
}
func (s *Server) AddChain(ctx context.Context, req *apemanager_grpc.AddChainRequest) (*apemanager_grpc.AddChainResponse, error) {
v2req := new(apemanager_v2.AddChainRequest)
if err := v2req.FromGRPCMessage(req); err != nil {
return nil, err
}
resp, err := s.srv.AddChain(ctx, v2req)
if err != nil {
return nil, err
}
return resp.ToGRPCMessage().(*apemanager_grpc.AddChainResponse), nil
}
func (s *Server) RemoveChain(ctx context.Context, req *apemanager_grpc.RemoveChainRequest) (*apemanager_grpc.RemoveChainResponse, error) {
v2req := new(apemanager_v2.RemoveChainRequest)
if err := v2req.FromGRPCMessage(req); err != nil {
return nil, err
}
resp, err := s.srv.RemoveChain(ctx, v2req)
if err != nil {
return nil, err
}
return resp.ToGRPCMessage().(*apemanager_grpc.RemoveChainResponse), nil
}
func (s *Server) ListChains(ctx context.Context, req *apemanager_grpc.ListChainsRequest) (*apemanager_grpc.ListChainsResponse, error) {
v2req := new(apemanager_v2.ListChainsRequest)
if err := v2req.FromGRPCMessage(req); err != nil {
return nil, err
}
resp, err := s.srv.ListChains(ctx, v2req)
if err != nil {
return nil, err
}
return resp.ToGRPCMessage().(*apemanager_grpc.ListChainsResponse), nil
}