From 0d4fbcb7cf012fe74ca0ef3b5bdfa352e09dd96f Mon Sep 17 00:00:00 2001 From: Kiel barry Date: Wed, 2 May 2018 17:31:25 -0700 Subject: [PATCH] rpc/*: golint error with context as last parameter --- rpc/http.go | 2 +- rpc/inproc.go | 2 +- rpc/json.go | 2 +- rpc/server.go | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rpc/http.go b/rpc/http.go index 0c2e060fb4..feaa7348c4 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -191,7 +191,7 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { defer codec.Close() w.Header().Set("content-type", contentType) - srv.ServeSingleRequest(codec, OptionMethodInvocation, ctx) + srv.ServeSingleRequest(ctx, codec, OptionMethodInvocation) } // validateRequest returns a non-zero response code and error message if the diff --git a/rpc/inproc.go b/rpc/inproc.go index 595a7ca651..cbe65d10e7 100644 --- a/rpc/inproc.go +++ b/rpc/inproc.go @@ -21,7 +21,7 @@ import ( "net" ) -// NewInProcClient attaches an in-process connection to the given RPC server. +// DialInProc attaches an in-process connection to the given RPC server. func DialInProc(handler *Server) *Client { initctx := context.Background() c, _ := newClient(initctx, func(context.Context) (net.Conn, error) { diff --git a/rpc/json.go b/rpc/json.go index 837011f51b..c53dc60c95 100644 --- a/rpc/json.go +++ b/rpc/json.go @@ -368,4 +368,4 @@ func (c *jsonCodec) Close() { // Closed returns a channel which will be closed when Close is called func (c *jsonCodec) Closed() <-chan interface{} { return c.closed -} +} \ No newline at end of file diff --git a/rpc/server.go b/rpc/server.go index 0f29035edb..7f304d8d93 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -125,7 +125,7 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error { // If singleShot is true it will process a single request, otherwise it will handle // requests until the codec returns an error when reading a request (in most cases // an EOF). It executes requests in parallel when singleShot is false. -func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecOption, ctx context.Context) error { +func (s *Server) serveRequest(ctx context.Context, codec ServerCodec, singleShot bool, options CodecOption) error { var pend sync.WaitGroup defer func() { @@ -216,14 +216,14 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO // stopped. In either case the codec is closed. func (s *Server) ServeCodec(codec ServerCodec, options CodecOption) { defer codec.Close() - s.serveRequest(codec, false, options, context.Background()) + s.serveRequest(context.Background(), codec, false, options) } // ServeSingleRequest reads and processes a single RPC request from the given codec. It will not // close the codec unless a non-recoverable error has occurred. Note, this method will return after // a single request has been processed! -func (s *Server) ServeSingleRequest(codec ServerCodec, options CodecOption, ctx context.Context) { - s.serveRequest(codec, true, options, ctx) +func (s *Server) ServeSingleRequest(ctx context.Context, codec ServerCodec, options CodecOption) { + s.serveRequest(ctx, codec, true, options) } // Stop will stop reading new requests, wait for stopPendingRequestTimeout to allow pending requests to finish,