Airat Arifullin
9b13a18aac
* 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>
63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
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
|
|
}
|