Airat Arifullin
542d3adcb2
* Introduce grpc server for apemanager service and its implementation in `pkg/services/apemanager`. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package apemanager
|
|
|
|
import (
|
|
"context"
|
|
"crypto/ecdsa"
|
|
|
|
apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
|
|
)
|
|
|
|
type signService struct {
|
|
sigSvc *util.SignService
|
|
|
|
next Server
|
|
}
|
|
|
|
func NewSignService(key *ecdsa.PrivateKey, next Server) Server {
|
|
return &signService{
|
|
sigSvc: util.NewUnarySignService(key),
|
|
next: next,
|
|
}
|
|
}
|
|
|
|
func (s *signService) AddChain(ctx context.Context, req *apemanager_v2.AddChainRequest) (*apemanager_v2.AddChainResponse, error) {
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
resp := new(apemanager_v2.AddChainResponse)
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
|
}
|
|
resp, err := util.EnsureNonNilResponse(s.next.AddChain(ctx, req))
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
|
}
|
|
|
|
func (s *signService) RemoveChain(ctx context.Context, req *apemanager_v2.RemoveChainRequest) (*apemanager_v2.RemoveChainResponse, error) {
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
resp := new(apemanager_v2.RemoveChainResponse)
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
|
}
|
|
resp, err := util.EnsureNonNilResponse(s.next.RemoveChain(ctx, req))
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
|
}
|
|
|
|
func (s *signService) ListChains(ctx context.Context, req *apemanager_v2.ListChainsRequest) (*apemanager_v2.ListChainsResponse, error) {
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
resp := new(apemanager_v2.ListChainsResponse)
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
|
}
|
|
resp, err := util.EnsureNonNilResponse(s.next.ListChains(ctx, req))
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
|
}
|