You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

doc.go 2.8 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by gapic-generator. DO NOT EDIT.
  15. // Package pubsub is an auto-generated package for the
  16. // Google Cloud Pub/Sub API.
  17. //
  18. // Provides reliable, many-to-many, asynchronous messaging between
  19. // applications.
  20. //
  21. // Use of Context
  22. //
  23. // The ctx passed to NewClient is used for authentication requests and
  24. // for creating the underlying connection, but is not used for subsequent calls.
  25. // Individual methods on the client use the ctx given to them.
  26. //
  27. // To close the open connection, use the Close() method.
  28. //
  29. // For information about setting deadlines, reusing contexts, and more
  30. // please visit godoc.org/cloud.google.com/go.
  31. //
  32. // Use the client at cloud.google.com/go/pubsub in preference to this.
  33. package pubsub // import "cloud.google.com/go/pubsub/apiv1"
  34. import (
  35. "context"
  36. "runtime"
  37. "strings"
  38. "unicode"
  39. "google.golang.org/grpc/metadata"
  40. )
  41. func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
  42. out, _ := metadata.FromOutgoingContext(ctx)
  43. out = out.Copy()
  44. for _, md := range mds {
  45. for k, v := range md {
  46. out[k] = append(out[k], v...)
  47. }
  48. }
  49. return metadata.NewOutgoingContext(ctx, out)
  50. }
  51. // DefaultAuthScopes reports the default set of authentication scopes to use with this package.
  52. func DefaultAuthScopes() []string {
  53. return []string{
  54. "https://www.googleapis.com/auth/cloud-platform",
  55. "https://www.googleapis.com/auth/pubsub",
  56. }
  57. }
  58. // versionGo returns the Go runtime version. The returned string
  59. // has no whitespace, suitable for reporting in header.
  60. func versionGo() string {
  61. const develPrefix = "devel +"
  62. s := runtime.Version()
  63. if strings.HasPrefix(s, develPrefix) {
  64. s = s[len(develPrefix):]
  65. if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
  66. s = s[:p]
  67. }
  68. return s
  69. }
  70. notSemverRune := func(r rune) bool {
  71. return strings.IndexRune("0123456789.", r) < 0
  72. }
  73. if strings.HasPrefix(s, "go1") {
  74. s = s[2:]
  75. var prerelease string
  76. if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
  77. s, prerelease = s[:p], s[p:]
  78. }
  79. if strings.HasSuffix(s, ".") {
  80. s += "0"
  81. } else if strings.Count(s, ".") < 2 {
  82. s += ".0"
  83. }
  84. if prerelease != "" {
  85. s += "-" + prerelease
  86. }
  87. return s
  88. }
  89. return "UNKNOWN"
  90. }
  91. const versionClient = "20190819"