[#13] services/object: Implement Delete handlers

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-25 19:12:36 +03:00 committed by Alex Vanin
parent 7e91fffd39
commit 7a6b62c552
2 changed files with 25 additions and 4 deletions

View file

@ -167,8 +167,17 @@ func (s *executorSvc) Search(ctx context.Context, req *object.SearchRequest) (ob
}, nil
}
func (*executorSvc) Delete(context.Context, *object.DeleteRequest) (*object.DeleteResponse, error) {
panic("implement me")
func (s *executorSvc) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) {
respBody, err := s.exec.Delete(ctx, req.GetBody())
if err != nil {
return nil, errors.Wrap(err, "could not execute Delete request")
}
resp := new(object.DeleteResponse)
resp.SetBody(respBody)
resp.SetMetaHeader(s.metaHeader)
return resp, nil
}
func (s *rangeStreamer) Recv() (*object.GetRangeResponse, error) {

View file

@ -18,6 +18,7 @@ type signService struct {
putService object.Service
rangeSigService *util.UnarySignService
headSigService *util.UnarySignService
delSigService *util.UnarySignService
}
type searchStreamSigner struct {
@ -72,6 +73,12 @@ func NewSignService(key *ecdsa.PrivateKey, svc object.Service) object.Service {
return svc.Head(ctx, req.(*object.HeadRequest))
},
),
delSigService: util.NewUnarySignService(
key,
func(ctx context.Context, req interface{}) (interface{}, error) {
return svc.Delete(ctx, req.(*object.DeleteRequest))
},
),
}
}
@ -167,8 +174,13 @@ func (s *signService) Search(ctx context.Context, req *object.SearchRequest) (ob
}, nil
}
func (s *signService) Delete(context.Context, *object.DeleteRequest) (*object.DeleteResponse, error) {
panic("implement me")
func (s *signService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) {
resp, err := s.delSigService.HandleUnaryRequest(ctx, req)
if err != nil {
return nil, err
}
return resp.(*object.DeleteResponse), nil
}
func (s *getRangeStreamSigner) Recv() (*object.GetRangeResponse, error) {