grpc: add WithWaitForHandshake

This change causes grpc-go to wait for the server to respond with a connection preface ("i'm properly configured and ready to communicate") rather than the default behavior of attempting to send data on a connection that has only been Dial'ed.

This may be related to the recent Pub/Sub issues. For example, perhaps the clients are trying to send large amounts of messages on servers that are not ready, causing the GFE to push back.

This is a fairly outlandish theory, but luckily this change has no negative consequence, and if nothing else it makes the code easier to reason about (rather than having to consider what's happening to data being sent on a non-ready connection).

This will become a default setting in a later version of grpc-go.

Change-Id: Ic6570a638f6f0b20d424b6c5c2fe31703690a798
Reviewed-on: https://code-review.googlesource.com/c/34410
Reviewed-by: Jonathan Amsterdam <jba@google.com>
1 file changed
tree: 2eff140c71682a25ac552b93c8c1a260b4fa1e68
  1. abusiveexperiencereport/
  2. acceleratedmobilepageurl/
  3. accesscontextmanager/
  4. adexchangebuyer/
  5. adexchangebuyer2/
  6. adexchangeseller/
  7. adexperiencereport/
  8. admin/
  9. adsense/
  10. adsensehost/
  11. alertcenter/
  12. analytics/
  13. analyticsreporting/
  14. androiddeviceprovisioning/
  15. androidenterprise/
  16. androidmanagement/
  17. androidpublisher/
  18. appengine/
  19. appsactivity/
  20. appstate/
  21. bigquery/
  22. bigquerydatatransfer/
  23. binaryauthorization/
  24. blogger/
  25. books/
  26. calendar/
  27. chat/
  28. civicinfo/
  29. classroom/
  30. cloudasset/
  31. cloudbilling/
  32. cloudbuild/
  33. clouddebugger/
  34. clouderrorreporting/
  35. cloudfunctions/
  36. cloudiot/
  37. cloudkms/
  38. cloudmonitoring/
  39. cloudprofiler/
  40. cloudresourcemanager/
  41. cloudshell/
  42. cloudtasks/
  43. cloudtrace/
  44. clouduseraccounts/
  45. composer/
  46. compute/
  47. consumersurveys/
  48. container/
  49. content/
  50. customsearch/
  51. dataflow/
  52. dataproc/
  53. datastore/
  54. deploymentmanager/
  55. dfareporting/
  56. dialogflow/
  57. digitalassetlinks/
  58. discovery/
  59. dlp/
  60. dns/
  61. doubleclickbidmanager/
  62. doubleclicksearch/
  63. drive/
  64. examples/
  65. file/
  66. firebasedynamiclinks/
  67. firebasehosting/
  68. firebaseremoteconfig/
  69. firebaserules/
  70. firestore/
  71. fitness/
  72. fusiontables/
  73. games/
  74. gamesconfiguration/
  75. gamesmanagement/
  76. genomics/
  77. gensupport/
  78. gmail/
  79. google-api-go-generator/
  80. googleapi/
  81. groupsmigration/
  82. groupssettings/
  83. iam/
  84. iamcredentials/
  85. iap/
  86. identitytoolkit/
  87. indexing/
  88. integration-tests/
  89. internal/
  90. iterator/
  91. jobs/
  92. kgsearch/
  93. language/
  94. lib/
  95. licensing/
  96. logging/
  97. manufacturers/
  98. mirror/
  99. ml/
  100. monitoring/
  101. oauth2/
  102. option/
  103. oslogin/
  104. pagespeedonline/
  105. partners/
  106. people/
  107. photoslibrary/
  108. playcustomapp/
  109. playmoviespartner/
  110. plus/
  111. plusdomains/
  112. poly/
  113. prediction/
  114. proximitybeacon/
  115. pubsub/
  116. qpxexpress/
  117. redis/
  118. replicapool/
  119. replicapoolupdater/
  120. reseller/
  121. resourceviews/
  122. runtimeconfig/
  123. safebrowsing/
  124. script/
  125. searchconsole/
  126. servicebroker/
  127. serviceconsumermanagement/
  128. servicecontrol/
  129. servicemanagement/
  130. servicenetworking/
  131. serviceusage/
  132. serviceuser/
  133. sheets/
  134. siteverification/
  135. slides/
  136. sourcerepo/
  137. spanner/
  138. spectrum/
  139. speech/
  140. sqladmin/
  141. storage/
  142. storagetransfer/
  143. streetviewpublish/
  144. support/
  145. surveys/
  146. tagmanager/
  147. taskqueue/
  148. tasks/
  149. testing/
  150. texttospeech/
  151. toolresults/
  152. tpu/
  153. tracing/
  154. translate/
  155. transport/
  156. urlshortener/
  157. vault/
  158. videointelligence/
  159. vision/
  160. webfonts/
  161. webmasters/
  162. websecurityscanner/
  163. youtube/
  164. youtubeanalytics/
  165. youtubereporting/
  166. .gitignore
  167. .hgtags
  168. .travis.yml
  169. api-list.json
  170. AUTHORS
  171. CONTRIBUTING.md
  172. CONTRIBUTORS
  173. GettingStarted.md
  174. key.json.enc
  175. LICENSE
  176. NOTES
  177. README.md
  178. TODO
README.md

Google APIs Client Library for Go

Getting Started

$ go get google.golang.org/api/tasks/v1
$ go get google.golang.org/api/moderator/v1
$ go get google.golang.org/api/urlshortener/v1
... etc ...

and using:

package main

import (
	"net/http"

	"google.golang.org/api/urlshortener/v1"
)

func main() {
	svc, err := urlshortener.New(http.DefaultClient)
	// ...
}

Status

Build Status GoDoc

These are auto-generated Go libraries from the Google Discovery Service's JSON description files of the available “new style” Google APIs.

Due to the auto-generated nature of this collection of libraries, complete APIs or specific versions can appear or go away without notice. As a result, you should always locally vendor any API(s) that your code relies upon.

These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.

If you're working with Google Cloud Platform APIs such as Datastore or Pub/Sub, consider using the Cloud Client Libraries for Go instead. These are the new and idiomatic Go libraries targeted specifically at Google Cloud Platform Services.

The generator itself and the code it produces are beta. Some APIs are alpha/beta, and indicated as such in the import path (e.g., “google.golang.org/api/someapi/v1alpha”).

Application Default Credentials Example

Application Default Credentials provide a simplified way to obtain credentials for authenticating with Google APIs.

The Application Default Credentials authenticate as the application itself, which make them great for working with Google Cloud APIs like Storage or Datastore. They are the recommended form of authentication when building applications that run on Google Compute Engine or Google App Engine.

Default credentials are provided by the golang.org/x/oauth2/google package. To use them, add the following import:

import "golang.org/x/oauth2/google"

Some credentials types require you to specify scopes, and service entry points may not inject them. If you encounter this situation you may need to specify scopes as follows:

import (
        "golang.org/x/net/context"
        "golang.org/x/oauth2/google"
        "google.golang.org/api/compute/v1"
)

func main() {
        // Use oauth2.NoContext if there isn't a good context to pass in.
        ctx := context.Background()

        client, err := google.DefaultClient(ctx, compute.ComputeScope)
        if err != nil {
                //...
        }
        computeService, err := compute.New(client)
        if err != nil {
                //...
        }
}

If you need a oauth2.TokenSource, use the DefaultTokenSource function:

ts, err := google.DefaultTokenSource(ctx, scope1, scope2, ...)
if err != nil {
        //...
}
client := oauth2.NewClient(ctx, ts)

See also: golang.org/x/oauth2/google package documentation.