forked from TrueCloudLab/frostfs-node
[#302] Fix golint underscore linter errors
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7e30b0b9c8
commit
74a68af5c2
5 changed files with 10 additions and 43 deletions
|
@ -19,7 +19,7 @@ func main() {
|
||||||
|
|
||||||
c := initCfg(*configFile)
|
c := initCfg(*configFile)
|
||||||
|
|
||||||
init_(c)
|
initApp(c)
|
||||||
|
|
||||||
bootUp(c)
|
bootUp(c)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func main() {
|
||||||
shutdown(c)
|
shutdown(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init_(c *cfg) {
|
func initApp(c *cfg) {
|
||||||
c.ctx = grace.NewGracefulContext(nil)
|
c.ctx = grace.NewGracefulContext(nil)
|
||||||
|
|
||||||
initGRPC(c)
|
initGRPC(c)
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (s *getStreamResponser) Send(resp *object.GetResponse) error {
|
||||||
func (s *ResponseService) Get(req *object.GetRequest, stream GetObjectStream) error {
|
func (s *ResponseService) Get(req *object.GetRequest, stream GetObjectStream) error {
|
||||||
return s.svc.Get(req, &getStreamResponser{
|
return s.svc.Get(req, &getStreamResponser{
|
||||||
ServerStream: stream,
|
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))
|
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 {
|
func (s *ResponseService) Search(req *object.SearchRequest, stream SearchStream) error {
|
||||||
return s.svc.Search(req, &searchStreamResponser{
|
return s.svc.Search(req, &searchStreamResponser{
|
||||||
ServerStream: stream,
|
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))
|
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 {
|
func (s *ResponseService) GetRange(req *object.GetRangeRequest, stream GetObjectRangeStream) error {
|
||||||
return s.svc.GetRange(req, &getRangeStreamResponser{
|
return s.svc.GetRange(req, &getRangeStreamResponser{
|
||||||
ServerStream: stream,
|
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))
|
return stream.Send(resp.(*object.GetRangeResponse))
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (s *getStreamSigner) Send(resp *object.GetResponse) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignService) Get(req *object.GetRequest, stream GetObjectStream) 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 {
|
func(resp util.ResponseMessage) error {
|
||||||
return stream.Send(resp.(*object.GetResponse))
|
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 {
|
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 {
|
func(resp util.ResponseMessage) error {
|
||||||
return stream.Send(resp.(*object.SearchResponse))
|
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 {
|
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 {
|
func(resp util.ResponseMessage) error {
|
||||||
return stream.Send(resp.(*object.GetRangeResponse))
|
return stream.Send(resp.(*object.GetRangeResponse))
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package response
|
package response
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/util"
|
"github.com/nspcc-dev/neofs-node/pkg/services/util"
|
||||||
"github.com/pkg/errors"
|
"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.
|
// 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) {
|
func (s *Service) HandleServerStreamRequest(respWriter util.ResponseMessageWriter) util.ResponseMessageWriter {
|
||||||
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 {
|
|
||||||
return func(resp util.ResponseMessage) error {
|
return func(resp util.ResponseMessage) error {
|
||||||
setMeta(resp, s.cfg)
|
setMeta(resp, s.cfg)
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@ type SignService struct {
|
||||||
|
|
||||||
type ResponseMessageWriter func(ResponseMessage) error
|
type ResponseMessageWriter func(ResponseMessage) error
|
||||||
|
|
||||||
type ServerStreamHandler_ func(interface{}, ResponseMessageWriter) (ResponseMessageWriter, error)
|
|
||||||
|
|
||||||
type ServerStreamHandler func(context.Context, interface{}) (ResponseMessageReader, error)
|
type ServerStreamHandler func(context.Context, interface{}) (ResponseMessageReader, error)
|
||||||
|
|
||||||
type ResponseMessageReader func() (ResponseMessage, error)
|
type ResponseMessageReader func() (ResponseMessage, error)
|
||||||
|
@ -96,24 +94,7 @@ func (s *ResponseMessageStreamer) Recv() (ResponseMessage, error) {
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignService) HandleServerStreamRequest(ctx context.Context, req interface{}, handler ServerStreamHandler) (*ResponseMessageStreamer, 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")
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
// verify request signatures
|
// verify request signatures
|
||||||
if err := signature.VerifyServiceMessage(req); err != nil {
|
if err := signature.VerifyServiceMessage(req); err != nil {
|
||||||
return nil, errors.Wrap(err, "could not verify request")
|
return nil, errors.Wrap(err, "could not verify request")
|
||||||
|
|
Loading…
Reference in a new issue