From 74a68af5c29f0b2caab9a57722a6746e487a7a56 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Mon, 11 Jan 2021 18:17:06 +0300 Subject: [PATCH] [#302] Fix golint underscore linter errors Signed-off-by: Alex Vanin --- cmd/neofs-node/main.go | 4 ++-- pkg/services/object/response.go | 6 +++--- pkg/services/object/sign.go | 6 +++--- pkg/services/util/response/server_stream.go | 16 +--------------- pkg/services/util/sign.go | 21 +-------------------- 5 files changed, 10 insertions(+), 43 deletions(-) diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index 320458ee..218e5c7f 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -19,7 +19,7 @@ func main() { c := initCfg(*configFile) - init_(c) + initApp(c) bootUp(c) @@ -28,7 +28,7 @@ func main() { shutdown(c) } -func init_(c *cfg) { +func initApp(c *cfg) { c.ctx = grace.NewGracefulContext(nil) initGRPC(c) diff --git a/pkg/services/object/response.go b/pkg/services/object/response.go index f60eb9a6..948bb0dc 100644 --- a/pkg/services/object/response.go +++ b/pkg/services/object/response.go @@ -53,7 +53,7 @@ func (s *getStreamResponser) Send(resp *object.GetResponse) error { func (s *ResponseService) Get(req *object.GetRequest, stream GetObjectStream) error { return s.svc.Get(req, &getStreamResponser{ ServerStream: stream, - respWriter: s.respSvc.HandleServerStreamRequest_(func(resp util.ResponseMessage) error { + respWriter: s.respSvc.HandleServerStreamRequest(func(resp util.ResponseMessage) error { return stream.Send(resp.(*object.GetResponse)) }), }) @@ -110,7 +110,7 @@ func (s *searchStreamResponser) Send(resp *object.SearchResponse) error { func (s *ResponseService) Search(req *object.SearchRequest, stream SearchStream) error { return s.svc.Search(req, &searchStreamResponser{ ServerStream: stream, - respWriter: s.respSvc.HandleServerStreamRequest_(func(resp util.ResponseMessage) error { + respWriter: s.respSvc.HandleServerStreamRequest(func(resp util.ResponseMessage) error { return stream.Send(resp.(*object.SearchResponse)) }), }) @@ -136,7 +136,7 @@ func (s *getRangeStreamResponser) Send(resp *object.GetRangeResponse) error { func (s *ResponseService) GetRange(req *object.GetRangeRequest, stream GetObjectRangeStream) error { return s.svc.GetRange(req, &getRangeStreamResponser{ ServerStream: stream, - respWriter: s.respSvc.HandleServerStreamRequest_(func(resp util.ResponseMessage) error { + respWriter: s.respSvc.HandleServerStreamRequest(func(resp util.ResponseMessage) error { return stream.Send(resp.(*object.GetRangeResponse)) }), }) diff --git a/pkg/services/object/sign.go b/pkg/services/object/sign.go index 4d4220f1..0b9e3ff0 100644 --- a/pkg/services/object/sign.go +++ b/pkg/services/object/sign.go @@ -52,7 +52,7 @@ func (s *getStreamSigner) Send(resp *object.GetResponse) error { } func (s *SignService) Get(req *object.GetRequest, stream GetObjectStream) error { - respWriter, err := s.sigSvc.HandleServerStreamRequest_(req, + respWriter, err := s.sigSvc.HandleServerStreamRequest(req, func(resp util.ResponseMessage) error { return stream.Send(resp.(*object.GetResponse)) }, @@ -116,7 +116,7 @@ func (s *searchStreamSigner) Send(resp *object.SearchResponse) error { } func (s *SignService) Search(req *object.SearchRequest, stream SearchStream) error { - respWriter, err := s.sigSvc.HandleServerStreamRequest_(req, + respWriter, err := s.sigSvc.HandleServerStreamRequest(req, func(resp util.ResponseMessage) error { return stream.Send(resp.(*object.SearchResponse)) }, @@ -149,7 +149,7 @@ func (s *getRangeStreamSigner) Send(resp *object.GetRangeResponse) error { } func (s *SignService) GetRange(req *object.GetRangeRequest, stream GetObjectRangeStream) error { - respWriter, err := s.sigSvc.HandleServerStreamRequest_(req, + respWriter, err := s.sigSvc.HandleServerStreamRequest(req, func(resp util.ResponseMessage) error { return stream.Send(resp.(*object.GetRangeResponse)) }, diff --git a/pkg/services/util/response/server_stream.go b/pkg/services/util/response/server_stream.go index c903507a..102d582b 100644 --- a/pkg/services/util/response/server_stream.go +++ b/pkg/services/util/response/server_stream.go @@ -1,8 +1,6 @@ package response import ( - "context" - "github.com/nspcc-dev/neofs-node/pkg/services/util" "github.com/pkg/errors" ) @@ -29,19 +27,7 @@ func (s *ServerMessageStreamer) Recv() (util.ResponseMessage, error) { } // HandleServerStreamRequest builds internal streamer via handlers, wraps it to ServerMessageStreamer and returns the result. -func (s *Service) HandleServerStreamRequest(ctx context.Context, req interface{}, handler util.ServerStreamHandler) (*ServerMessageStreamer, error) { - msgRdr, err := handler(ctx, req) - if err != nil { - return nil, errors.Wrap(err, "could not create message reader") - } - - return &ServerMessageStreamer{ - cfg: s.cfg, - recv: msgRdr, - }, nil -} - -func (s *Service) HandleServerStreamRequest_(respWriter util.ResponseMessageWriter) util.ResponseMessageWriter { +func (s *Service) HandleServerStreamRequest(respWriter util.ResponseMessageWriter) util.ResponseMessageWriter { return func(resp util.ResponseMessage) error { setMeta(resp, s.cfg) diff --git a/pkg/services/util/sign.go b/pkg/services/util/sign.go index 2f055007..e9ab1336 100644 --- a/pkg/services/util/sign.go +++ b/pkg/services/util/sign.go @@ -23,8 +23,6 @@ type SignService struct { type ResponseMessageWriter func(ResponseMessage) error -type ServerStreamHandler_ func(interface{}, ResponseMessageWriter) (ResponseMessageWriter, error) - type ServerStreamHandler func(context.Context, interface{}) (ResponseMessageReader, error) type ResponseMessageReader func() (ResponseMessage, error) @@ -96,24 +94,7 @@ func (s *ResponseMessageStreamer) Recv() (ResponseMessage, error) { return m, nil } -func (s *SignService) HandleServerStreamRequest(ctx context.Context, req interface{}, handler ServerStreamHandler) (*ResponseMessageStreamer, error) { - // verify request signatures - if err := signature.VerifyServiceMessage(req); err != nil { - return nil, errors.Wrap(err, "could not verify request") - } - - msgRdr, err := handler(ctx, req) - if err != nil { - return nil, errors.Wrap(err, "could not create message reader") - } - - return &ResponseMessageStreamer{ - key: s.key, - recv: msgRdr, - }, nil -} - -func (s *SignService) HandleServerStreamRequest_(req interface{}, respWriter ResponseMessageWriter) (ResponseMessageWriter, error) { +func (s *SignService) HandleServerStreamRequest(req interface{}, respWriter ResponseMessageWriter) (ResponseMessageWriter, error) { // verify request signatures if err := signature.VerifyServiceMessage(req); err != nil { return nil, errors.Wrap(err, "could not verify request")