diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2020-03-24 12:04:29 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2020-03-25 15:42:05 +0300 |
commit | 1ce103c128b54bbe98c4a7681b32707e043405dd (patch) | |
tree | 34602b44ee5422824e4bc1a5c0da58a14b17339c /internal/praefect/grpc-proxy | |
parent | 1cb13f84625afc440bfa22f2493c17c5f6b78ecf (diff) |
Static code analysis with govet
govet tool helps to identify a lot of common mistakes such as
unused\dead\unreachable code, wrong context usage\copy by value
of the locking primitives, etc.
It is enabled with disabled check for `uses unkeyed fields`.
Diffstat (limited to 'internal/praefect/grpc-proxy')
-rw-r--r-- | internal/praefect/grpc-proxy/proxy/handler.go | 1 | ||||
-rw-r--r-- | internal/praefect/grpc-proxy/proxy/handler_test.go | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/internal/praefect/grpc-proxy/proxy/handler.go b/internal/praefect/grpc-proxy/proxy/handler.go index 69012235e..5ea376e07 100644 --- a/internal/praefect/grpc-proxy/proxy/handler.go +++ b/internal/praefect/grpc-proxy/proxy/handler.go @@ -109,6 +109,7 @@ func (s *handler) handler(srv interface{}, serverStream grpc.ServerStream) error defer params.RequestFinalizer() clientCtx, clientCancel := context.WithCancel(params.Context()) + defer clientCancel() // TODO(mwitkow): Add a `forwarded` header to metadata, https://en.wikipedia.org/wiki/X-Forwarded-For. clientStream, err := grpc.NewClientStream(clientCtx, clientStreamDescForProxying, params.Conn(), fullMethodName, params.CallOptions()...) if err != nil { diff --git a/internal/praefect/grpc-proxy/proxy/handler_test.go b/internal/praefect/grpc-proxy/proxy/handler_test.go index 55e5a800d..0e247d8bd 100644 --- a/internal/praefect/grpc-proxy/proxy/handler_test.go +++ b/internal/praefect/grpc-proxy/proxy/handler_test.go @@ -140,7 +140,7 @@ type ProxyHappySuite struct { func (s *ProxyHappySuite) ctx() context.Context { // Make all RPC calls last at most 1 sec, meaning all async issues or deadlock will not kill tests. - ctx, _ := context.WithTimeout(context.TODO(), 120*time.Second) + ctx, _ := context.WithTimeout(context.TODO(), 120*time.Second) // nolint: govet return ctx } |