[#13] services/util: Rename UnarySignService to SingService

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-26 12:43:39 +03:00 committed by Alex Vanin
parent 75162d1f8d
commit d54a5d4f66
5 changed files with 31 additions and 31 deletions

View file

@ -9,20 +9,20 @@ import (
)
type signService struct {
unarySigService *util.UnarySignService
sigSvc *util.SignService
svc accounting.Service
}
func NewSignService(key *ecdsa.PrivateKey, svc accounting.Service) accounting.Service {
return &signService{
unarySigService: util.NewUnarySignService(key),
svc: svc,
sigSvc: util.NewUnarySignService(key),
svc: svc,
}
}
func (s *signService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.Balance(ctx, req.(*accounting.BalanceRequest))
},

View file

@ -9,20 +9,20 @@ import (
)
type signService struct {
unarySigService *util.UnarySignService
sigSvc *util.SignService
svc container.Service
}
func NewSignService(key *ecdsa.PrivateKey, svc container.Service) container.Service {
return &signService{
unarySigService: util.NewUnarySignService(key),
svc: svc,
sigSvc: util.NewUnarySignService(key),
svc: svc,
}
}
func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.Put(ctx, req.(*container.PutRequest))
},
@ -35,7 +35,7 @@ func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*cont
}
func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.Get(ctx, req.(*container.GetRequest))
},
@ -48,7 +48,7 @@ func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest)
}
func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.Delete(ctx, req.(*container.DeleteRequest))
},
@ -61,7 +61,7 @@ func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*cont
}
func (s *signService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.List(ctx, req.(*container.ListRequest))
},
@ -74,7 +74,7 @@ func (s *signService) List(ctx context.Context, req *container.ListRequest) (*co
}
func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest))
},
@ -87,7 +87,7 @@ func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExte
}
func (s *signService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest))
},

View file

@ -13,7 +13,7 @@ import (
type signService struct {
key *ecdsa.PrivateKey
unarySigService *util.UnarySignService
sigSvc *util.SignService
svc object.Service
}
@ -38,9 +38,9 @@ type getRangeStreamSigner struct {
func NewSignService(key *ecdsa.PrivateKey, svc object.Service) object.Service {
return &signService{
key: key,
unarySigService: util.NewUnarySignService(key),
svc: svc,
key: key,
sigSvc: util.NewUnarySignService(key),
svc: svc,
}
}
@ -54,7 +54,7 @@ func (s *getStreamSigner) Recv() (*object.GetResponse, error) {
}
func (s *signService) Get(ctx context.Context, req *object.GetRequest) (object.GetObjectStreamer, error) {
stream, err := s.unarySigService.HandleServerStreamRequest(ctx, req,
stream, err := s.sigSvc.HandleServerStreamRequest(ctx, req,
func(ctx context.Context, req interface{}) (util.MessageReader, error) {
stream, err := s.svc.Get(ctx, req.(*object.GetRequest))
if err != nil {
@ -109,7 +109,7 @@ func (s *signService) Put(ctx context.Context) (object.PutObjectStreamer, error)
}
func (s *signService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.Head(ctx, req.(*object.HeadRequest))
},
@ -131,7 +131,7 @@ func (s *searchStreamSigner) Recv() (*object.SearchResponse, error) {
}
func (s *signService) Search(ctx context.Context, req *object.SearchRequest) (object.SearchObjectStreamer, error) {
stream, err := s.unarySigService.HandleServerStreamRequest(ctx, req,
stream, err := s.sigSvc.HandleServerStreamRequest(ctx, req,
func(ctx context.Context, req interface{}) (util.MessageReader, error) {
stream, err := s.svc.Search(ctx, req.(*object.SearchRequest))
if err != nil {
@ -153,7 +153,7 @@ func (s *signService) Search(ctx context.Context, req *object.SearchRequest) (ob
}
func (s *signService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.Delete(ctx, req.(*object.DeleteRequest))
},
@ -175,7 +175,7 @@ func (s *getRangeStreamSigner) Recv() (*object.GetRangeResponse, error) {
}
func (s *signService) GetRange(ctx context.Context, req *object.GetRangeRequest) (object.GetRangeObjectStreamer, error) {
stream, err := s.unarySigService.HandleServerStreamRequest(ctx, req,
stream, err := s.sigSvc.HandleServerStreamRequest(ctx, req,
func(ctx context.Context, req interface{}) (util.MessageReader, error) {
stream, err := s.svc.GetRange(ctx, req.(*object.GetRangeRequest))
if err != nil {
@ -197,7 +197,7 @@ func (s *signService) GetRange(ctx context.Context, req *object.GetRangeRequest)
}
func (s *signService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest))
},

View file

@ -9,19 +9,19 @@ import (
)
type signService struct {
unarySigService *util.UnarySignService
sigSvc *util.SignService
svc session.Service
}
func NewSignService(key *ecdsa.PrivateKey, svc session.Service) session.Service {
return &signService{
unarySigService: util.NewUnarySignService(key),
sigSvc: util.NewUnarySignService(key),
}
}
func (s *signService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) {
resp, err := s.unarySigService.HandleUnaryRequest(ctx, req,
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req interface{}) (interface{}, error) {
return s.svc.Create(ctx, req.(*session.CreateRequest))
},

View file

@ -10,7 +10,7 @@ import (
type UnaryHandler func(context.Context, interface{}) (interface{}, error)
type UnarySignService struct {
type SignService struct {
key *ecdsa.PrivateKey
}
@ -24,8 +24,8 @@ type MessageStreamer struct {
recv MessageReader
}
func NewUnarySignService(key *ecdsa.PrivateKey) *UnarySignService {
return &UnarySignService{
func NewUnarySignService(key *ecdsa.PrivateKey) *SignService {
return &SignService{
key: key,
}
}
@ -43,7 +43,7 @@ func (s *MessageStreamer) Recv() (interface{}, error) {
return m, nil
}
func (s *UnarySignService) HandleServerStreamRequest(ctx context.Context, req interface{}, handler ServerStreamHandler) (*MessageStreamer, error) {
func (s *SignService) HandleServerStreamRequest(ctx context.Context, req interface{}, handler ServerStreamHandler) (*MessageStreamer, error) {
// verify request signatures
if err := signature.VerifyServiceMessage(req); err != nil {
return nil, errors.Wrap(err, "could not verify request")
@ -60,7 +60,7 @@ func (s *UnarySignService) HandleServerStreamRequest(ctx context.Context, req in
}, nil
}
func (s *UnarySignService) HandleUnaryRequest(ctx context.Context, req interface{}, handler UnaryHandler) (interface{}, error) {
func (s *SignService) HandleUnaryRequest(ctx context.Context, req interface{}, handler UnaryHandler) (interface{}, error) {
// verify request signatures
if err := signature.VerifyServiceMessage(req); err != nil {
return nil, errors.Wrap(err, "could not verify request")