diff --git a/client/proxy.go b/client/proxy.go index 32fc15b..1ba7489 100644 --- a/client/proxy.go +++ b/client/proxy.go @@ -115,7 +115,7 @@ func createTransport(tlsClientConf *tls.Config, forceHTTP2 bool, extraH2ALPNs [] TLSClientConfig: tlsClientConf, } if tlsClientConf == nil { - transport.DialTLS = func(network, addr string, _ *tls.Config) (net.Conn, error) { + transport.DialTLSContext = func(_ context.Context, network, addr string, _ *tls.Config) (net.Conn, error) { return net.Dial(network, addr) } } @@ -151,7 +151,7 @@ func createClientProxy(endpoint string, tlsClientConf *tls.Config, forceHTTP2, f return makeProxyServer(proxy) } -// ConnectViaProxy establishes a gRPC client connection via a HTTP/2 proxy that handles endpoints behind HTTP/1.x proxies. +// ConnectViaProxy establishes a gRPC client connection via an HTTP/2 proxy that handles endpoints behind HTTP/1.x proxies. // Use the WithWebSocket() ConnectOption if you want to connect to a server via WebSocket. // Otherwise, setting it to false will use a gRPC-Web "downgrade", as needed. // diff --git a/internal/concurrency/do.go b/internal/concurrency/do.go index 354cf07..20cc38f 100644 --- a/internal/concurrency/do.go +++ b/internal/concurrency/do.go @@ -18,13 +18,6 @@ import ( "time" ) -// Do performs the action as soon as the waitable is done. -// It blocks indefinitely until that happens. -func Do(w Waitable, action func()) { - Wait(w) - action() -} - // DoWithTimeout performs the action as soon as the waitable is done. // It gives up and returns after timeout, and returns a bool indicating whether // the action was performed or not. diff --git a/internal/concurrency/signal.go b/internal/concurrency/signal.go index 9a2dbbd..ec12f4b 100644 --- a/internal/concurrency/signal.go +++ b/internal/concurrency/signal.go @@ -19,6 +19,14 @@ import ( "unsafe" ) +var ( + closedCh = func() chan struct{} { + ch := make(chan struct{}) + close(ch) + return ch + }() +) + // Signal implements a signalling facility. Unlike sync.Cond, it is based on channels and can hence be used // in `select` statements. // There are two ways to instantiate a Signal. The preferred way is by calling `NewSignal()`, which will return a signal diff --git a/internal/concurrency/util.go b/internal/concurrency/util.go deleted file mode 100644 index acdb508..0000000 --- a/internal/concurrency/util.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2020 StackRox Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License - -package concurrency - -var ( - closedCh = func() chan struct{} { - ch := make(chan struct{}) - close(ch) - return ch - }() -) - -// ClosedChannel returns a struct{} channel that is closed. -func ClosedChannel() <-chan struct{} { - return closedCh -} diff --git a/internal/concurrency/wait.go b/internal/concurrency/wait.go index 1f9ebf3..ac5024b 100644 --- a/internal/concurrency/wait.go +++ b/internal/concurrency/wait.go @@ -16,12 +16,6 @@ package concurrency import "time" -// Never satisfies the Waitable interface, but will never be signaled -// Waiting will block indefinitely -func Never() WaitableChan { - return WaitableChan(nil) -} - // Wait waits indefinitely until the condition represented by the given Waitable is fulfilled. func Wait(w Waitable) { <-w.Done() @@ -55,22 +49,3 @@ func WaitWithTimeout(w Waitable, timeout time.Duration) bool { return false } } - -// WaitWithDeadline waits for the given Waitable until a specified deadline. It returns false if the deadline expired -// before the condition was fulfilled, true otherwise. -func WaitWithDeadline(w Waitable, deadline time.Time) bool { - timeout := time.Until(deadline) - return WaitWithTimeout(w, timeout) -} - -// WaitInContext waits for the given Waitable until a `parentContext` is done. Note that despite its name, -// `parentContext` can be any waitable, not just a context. -// It returns false if the parentContext is done first, true otherwise. -func WaitInContext(w Waitable, parentContext Waitable) bool { - select { - case <-w.Done(): - return true - case <-parentContext.Done(): - return false - } -} diff --git a/internal/size/size.go b/internal/size/size.go index 02e4b64..bd9ad3b 100644 --- a/internal/size/size.go +++ b/internal/size/size.go @@ -21,6 +21,4 @@ const ( KB = 1024 * B // MB = megabyte MB = 1024 * KB - // GB = gigabyte - GB = 1024 * MB ) diff --git a/server/server.go b/server/server.go index c501483..140aadb 100644 --- a/server/server.go +++ b/server/server.go @@ -138,7 +138,7 @@ func handleGRPCWeb(w http.ResponseWriter, req *http.Request, validPaths map[stri return } - // Tell the server we would accept trailers (the gRPC server currently (v1.29.1) doesn't check for this but it + // Tell the server we would accept trailers (the gRPC server currently (v1.29.1) doesn't check for this, but it // really should, as the purpose of the TE header according to the gRPC spec is to detect incompatible proxies). req.Header.Set("TE", "trailers") diff --git a/server/websocket_writer.go b/server/websocket_writer.go index 2c2fd5b..37b803b 100644 --- a/server/websocket_writer.go +++ b/server/websocket_writer.go @@ -86,7 +86,7 @@ func (w *wsResponseWriter) WriteHeader(statusCode int) { w.headerWritten = true } -// Flush is a No-Op since the underlying writer is a io.PipeWriter, +// Flush is a No-Op since the underlying writer is an io.PipeWriter, // which does no internal buffering. func (w *wsResponseWriter) Flush() {}