[#13] services/object: Implement GetRangeHash handlers

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-25 19:18:24 +03:00 committed by Alex Vanin
parent 7765671502
commit 0c83e84613
2 changed files with 31 additions and 10 deletions

View file

@ -205,6 +205,15 @@ func (s *executorSvc) GetRange(ctx context.Context, req *object.GetRangeRequest)
}, nil }, nil
} }
func (*executorSvc) GetRangeHash(context.Context, *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) { func (s *executorSvc) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
panic("implement me") respBody, err := s.exec.GetRangeHash(ctx, req.GetBody())
if err != nil {
return nil, errors.Wrap(err, "could not execute GetRangeHash request")
}
resp := new(object.GetRangeHashResponse)
resp.SetBody(respBody)
resp.SetMetaHeader(s.metaHeader)
return resp, nil
} }

View file

@ -19,6 +19,7 @@ type signService struct {
rangeSigService *util.UnarySignService rangeSigService *util.UnarySignService
headSigService *util.UnarySignService headSigService *util.UnarySignService
delSigService *util.UnarySignService delSigService *util.UnarySignService
rangeHashSigService *util.UnarySignService
} }
type searchStreamSigner struct { type searchStreamSigner struct {
@ -79,6 +80,12 @@ func NewSignService(key *ecdsa.PrivateKey, svc object.Service) object.Service {
return svc.Delete(ctx, req.(*object.DeleteRequest)) return svc.Delete(ctx, req.(*object.DeleteRequest))
}, },
), ),
rangeHashSigService: util.NewUnarySignService(
key,
func(ctx context.Context, req interface{}) (interface{}, error) {
return svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest))
},
),
} }
} }
@ -208,6 +215,11 @@ func (s *signService) GetRange(ctx context.Context, req *object.GetRangeRequest)
}, nil }, nil
} }
func (s *signService) GetRangeHash(context.Context, *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) { func (s *signService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
panic("implement me") resp, err := s.rangeHashSigService.HandleUnaryRequest(ctx, req)
if err != nil {
return nil, err
}
return resp.(*object.GetRangeHashResponse), nil
} }