diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2018-08-09 23:29:20 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2018-08-09 23:43:59 +0100 |
commit | 347c11ec42264c579eb3f19494e4f75ab8bb8f0d (patch) | |
tree | 0171d2a9bcd67e7b9f6a78bbf6af4627e59f5aa1 /vendor/google.golang.org/appengine/internal/net.go | |
parent | 9f8f0194a3c21e640a5b917f86bf204c014d730d (diff) |
Remove gRPC
This hasn't been enabled in a while due to gRPC limitations
Diffstat (limited to 'vendor/google.golang.org/appengine/internal/net.go')
-rw-r--r-- | vendor/google.golang.org/appengine/internal/net.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/vendor/google.golang.org/appengine/internal/net.go b/vendor/google.golang.org/appengine/internal/net.go deleted file mode 100644 index 3b94cf0..0000000 --- a/vendor/google.golang.org/appengine/internal/net.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 Google Inc. All rights reserved. -// Use of this source code is governed by the Apache 2.0 -// license that can be found in the LICENSE file. - -package internal - -// This file implements a network dialer that limits the number of concurrent connections. -// It is only used for API calls. - -import ( - "log" - "net" - "runtime" - "sync" - "time" -) - -var limitSem = make(chan int, 100) // TODO(dsymonds): Use environment variable. - -func limitRelease() { - // non-blocking - select { - case <-limitSem: - default: - // This should not normally happen. - log.Print("appengine: unbalanced limitSem release!") - } -} - -func limitDial(network, addr string) (net.Conn, error) { - limitSem <- 1 - - // Dial with a timeout in case the API host is MIA. - // The connection should normally be very fast. - conn, err := net.DialTimeout(network, addr, 500*time.Millisecond) - if err != nil { - limitRelease() - return nil, err - } - lc := &limitConn{Conn: conn} - runtime.SetFinalizer(lc, (*limitConn).Close) // shouldn't usually be required - return lc, nil -} - -type limitConn struct { - close sync.Once - net.Conn -} - -func (lc *limitConn) Close() error { - defer lc.close.Do(func() { - limitRelease() - runtime.SetFinalizer(lc, nil) - }) - return lc.Conn.Close() -} |