Skip to content

Commit

Permalink
chore(transport): remove support for go runtimes earlier than 1.16 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
quartzmo authored Feb 6, 2023
1 parent 4b4c9d4 commit 1651c38
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
26 changes: 0 additions & 26 deletions transport/http/configure_http2_go116.go

This file was deleted.

17 changes: 0 additions & 17 deletions transport/http/configure_http2_not_go116.go

This file was deleted.

14 changes: 12 additions & 2 deletions transport/http/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

"go.opencensus.io/plugin/ochttp"
"golang.org/x/net/http2"
"golang.org/x/oauth2"
"google.golang.org/api/googleapi/transport"
"google.golang.org/api/internal"
Expand Down Expand Up @@ -175,13 +176,22 @@ func defaultBaseTransport(ctx context.Context, clientCertSource cert.Source) htt
}
}

// If possible, configure http2 transport in order to use ReadIdleTimeout
// setting. This can only be done in Go 1.16 and up.
configureHTTP2(trans)

return trans
}

// configureHTTP2 configures the ReadIdleTimeout HTTP/2 option for the
// transport. This allows broken idle connections to be pruned more quickly,
// preventing the client from attempting to re-use connections that will no
// longer work.
func configureHTTP2(trans *http.Transport) {
http2Trans, err := http2.ConfigureTransports(trans)
if err == nil {
http2Trans.ReadIdleTimeout = time.Second * 31
}
}

// fallbackBaseTransport is used in <go1.13 as well as in the rare case if
// http.DefaultTransport has been reassigned something that's not a
// *http.Transport.
Expand Down

0 comments on commit 1651c38

Please sign in to comment.