google-cloud-pubsub 1.0.2 → 2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +16 -54
  3. data/CHANGELOG.md +464 -0
  4. data/CONTRIBUTING.md +328 -116
  5. data/EMULATOR.md +1 -1
  6. data/LOGGING.md +94 -2
  7. data/OVERVIEW.md +121 -68
  8. data/TROUBLESHOOTING.md +2 -8
  9. data/lib/google/cloud/pubsub/acknowledge_result.rb +79 -0
  10. data/lib/google/cloud/pubsub/async_publisher/batch.rb +319 -0
  11. data/lib/google/cloud/pubsub/async_publisher.rb +231 -156
  12. data/lib/google/cloud/pubsub/batch_publisher.rb +60 -30
  13. data/lib/google/cloud/pubsub/convert.rb +33 -7
  14. data/lib/google/cloud/pubsub/credentials.rb +2 -2
  15. data/lib/google/cloud/pubsub/errors.rb +93 -0
  16. data/lib/google/cloud/pubsub/flow_controller.rb +137 -0
  17. data/lib/google/cloud/pubsub/message.rb +45 -4
  18. data/lib/google/cloud/pubsub/policy.rb +3 -2
  19. data/lib/google/cloud/pubsub/project.rb +316 -49
  20. data/lib/google/cloud/pubsub/publish_result.rb +6 -1
  21. data/lib/google/cloud/pubsub/received_message.rb +171 -10
  22. data/lib/google/cloud/pubsub/retry_policy.rb +88 -0
  23. data/lib/google/cloud/pubsub/schema/list.rb +180 -0
  24. data/lib/google/cloud/pubsub/schema.rb +310 -0
  25. data/lib/google/cloud/pubsub/service.rb +285 -269
  26. data/lib/google/cloud/pubsub/snapshot/list.rb +4 -6
  27. data/lib/google/cloud/pubsub/snapshot.rb +5 -2
  28. data/lib/google/cloud/pubsub/subscriber/inventory.rb +69 -32
  29. data/lib/google/cloud/pubsub/subscriber/sequencer.rb +115 -0
  30. data/lib/google/cloud/pubsub/subscriber/stream.rb +108 -49
  31. data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +191 -30
  32. data/lib/google/cloud/pubsub/subscriber.rb +155 -45
  33. data/lib/google/cloud/pubsub/subscription/list.rb +4 -6
  34. data/lib/google/cloud/pubsub/subscription/push_config.rb +55 -31
  35. data/lib/google/cloud/pubsub/subscription.rb +561 -77
  36. data/lib/google/cloud/pubsub/topic/list.rb +4 -6
  37. data/lib/google/cloud/pubsub/topic.rb +372 -52
  38. data/lib/google/cloud/pubsub/version.rb +1 -1
  39. data/lib/google/cloud/pubsub.rb +35 -46
  40. data/lib/google-cloud-pubsub.rb +21 -27
  41. metadata +26 -189
  42. data/lib/google/cloud/pubsub/v1/credentials.rb +0 -41
  43. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +0 -21
  44. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +0 -21
  45. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +0 -21
  46. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -91
  47. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +0 -29
  48. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -222
  49. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -113
  50. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -744
  51. data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +0 -19
  52. data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -786
  53. data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -105
  54. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1385
  55. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -138
  56. data/lib/google/cloud/pubsub/v1.rb +0 -17
  57. data/lib/google/pubsub/v1/pubsub_pb.rb +0 -249
  58. data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -211
@@ -22,7 +22,18 @@ module Google
22
22
  ##
23
23
  # Configuration for a push delivery endpoint.
24
24
  #
25
- # @example
25
+ # @example Create a push config:
26
+ # require "google/cloud/pubsub"
27
+ #
28
+ # pubsub = Google::Cloud::PubSub.new
29
+ # topic = pubsub.topic "my-topic"
30
+ #
31
+ # push_config = Google::Cloud::PubSub::Subscription::PushConfig.new endpoint: "http://example.net/callback"
32
+ # push_config.set_oidc_token "service-account@example.net", "audience-header-value"
33
+ #
34
+ # sub = topic.subscribe "my-subscription", push_config: push_config
35
+ #
36
+ # @example Read a push config:
26
37
  # require "google/cloud/pubsub"
27
38
  #
28
39
  # pubsub = Google::Cloud::PubSub.new
@@ -32,7 +43,7 @@ module Google
32
43
  # sub.push_config.authentication.email #=> "user@example.com"
33
44
  # sub.push_config.authentication.audience #=> "client-12345"
34
45
  #
35
- # @example Update the push configuration by passing a block:
46
+ # @example Update a push config:
36
47
  # require "google/cloud/pubsub"
37
48
  #
38
49
  # pubsub = Google::Cloud::PubSub.new
@@ -45,14 +56,31 @@ module Google
45
56
  #
46
57
  class PushConfig
47
58
  ##
48
- # @private
49
- def initialize
59
+ # Creates a new push configuration.
60
+ #
61
+ # @param [String] endpoint A URL locating the endpoint to which messages should be pushed. For
62
+ # example, a Webhook endpoint might use `https://example.com/push`.
63
+ # @param [String] email The service account email to be used for generating the OIDC token.
64
+ # The caller must have the `iam.serviceAccounts.actAs` permission for the service account.
65
+ # @param [String] audience The audience to be used when generating OIDC token. The audience claim identifies
66
+ # the recipients that the JWT is intended for. The audience value is a single case-sensitive string. Having
67
+ # multiple values (array) for the audience field is not supported. More info about the OIDC JWT token
68
+ # audience here: https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the `endpoint`
69
+ # URL will be used.
70
+ #
71
+ def initialize endpoint: nil, email: nil, audience: nil
50
72
  @grpc = Google::Cloud::PubSub::V1::PushConfig.new
73
+
74
+ self.endpoint = endpoint unless endpoint.nil?
75
+
76
+ raise ArgumentError, "audience provided without email. Authentication is invalid" if audience && !email
77
+
78
+ set_oidc_token email, audience if email
51
79
  end
52
80
 
53
81
  ##
54
- # A URL locating the endpoint to which messages should be pushed. For
55
- # example, a Webhook endpoint might use "https://example.com/push".
82
+ # A URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might use
83
+ # `https://example.com/push`.
56
84
  #
57
85
  # @return [String]
58
86
  def endpoint
@@ -60,9 +88,8 @@ module Google
60
88
  end
61
89
 
62
90
  ##
63
- # Sets the URL locating the endpoint to which messages should be
64
- # pushed. For example, a Webhook endpoint might use
65
- # "https://example.com/push".
91
+ # Sets the URL locating the endpoint to which messages should be pushed. For example, a Webhook endpoint might
92
+ # use `https://example.com/push`.
66
93
  #
67
94
  # @param [String, nil] new_endpoint New URL value
68
95
  def endpoint= new_endpoint
@@ -70,8 +97,7 @@ module Google
70
97
  end
71
98
 
72
99
  ##
73
- # The authentication method used by push endpoints to verify the
74
- # source of push requests.
100
+ # The authentication method used by push endpoints to verify the source of push requests.
75
101
  #
76
102
  # @return [OidcToken, nil] An OIDC JWT token if specified, `nil`
77
103
  # otherwise.
@@ -82,8 +108,7 @@ module Google
82
108
  end
83
109
 
84
110
  ##
85
- # Sets the authentication method used by push endpoints to verify the
86
- # source of push requests.
111
+ # Sets the authentication method used by push endpoints to verify the source of push requests.
87
112
  #
88
113
  # @param [OidcToken, nil] new_auth An authentication value.
89
114
  def authentication= new_auth
@@ -118,13 +143,12 @@ module Google
118
143
  end
119
144
 
120
145
  ##
121
- # The format of the pushed message. This attribute indicates the
122
- # version of the data expected by the endpoint. This controls the
123
- # shape of the pushed message (i.e., its fields and metadata). The
124
- # endpoint version is based on the version of the Pub/Sub API.
146
+ # The format of the pushed message. This attribute indicates the version of the data expected by the endpoint.
147
+ # This controls the shape of the pushed message (i.e., its fields and metadata). The endpoint version is based
148
+ # on the version of the Pub/Sub API.
125
149
  #
126
- # If not present during the Subscription creation, it will default to
127
- # the version of the API used to make such call.
150
+ # If not present during the Subscription creation, it will default to the version of the API used to make such
151
+ # call.
128
152
  #
129
153
  # The possible values for this attribute are:
130
154
  #
@@ -182,7 +206,8 @@ module Google
182
206
  end
183
207
 
184
208
  ##
185
- # Service account email to be used for generating the OIDC token.
209
+ # The service account email to be used for generating the OIDC token. The caller must have the
210
+ # `iam.serviceAccounts.actAs` permission for the service account.
186
211
  #
187
212
  # @return [String]
188
213
  def email
@@ -190,7 +215,8 @@ module Google
190
215
  end
191
216
 
192
217
  ##
193
- # Service account email to be used for generating the OIDC token.
218
+ # Sets the service account email to be used for generating the OIDC token. The caller must have the
219
+ # `iam.serviceAccounts.actAs` permission for the service account.
194
220
  #
195
221
  # @param [String] new_email New service account email value.
196
222
  def email= new_email
@@ -198,15 +224,10 @@ module Google
198
224
  end
199
225
 
200
226
  ##
201
- # Audience to be used when generating OIDC token. The audience claim
202
- # identifies the recipients that the JWT is intended for. The
203
- # audience value is a single case-sensitive string.
204
- #
205
- # Having multiple values (array) for the audience field is not
206
- # supported.
207
- #
208
- # More info about the OIDC JWT token audience here:
209
- # https://tools.ietf.org/html/rfc7519#section-4.1.3
227
+ # The audience to be used when generating OIDC token. The audience claim identifies the recipients that
228
+ # the JWT is intended for. The audience value is a single case-sensitive string. Having multiple values
229
+ # (array) for the audience field is not supported. More info about the OIDC JWT token audience here:
230
+ # https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the `endpoint` URL will be used.
210
231
  #
211
232
  # @return [String]
212
233
  def audience
@@ -214,7 +235,10 @@ module Google
214
235
  end
215
236
 
216
237
  ##
217
- # Sets the audience to be used when generating OIDC token.
238
+ # Sets the audience to be used when generating OIDC token. The audience claim identifies the recipients that
239
+ # the JWT is intended for. The audience value is a single case-sensitive string. Having multiple values
240
+ # (array) for the audience field is not supported. More info about the OIDC JWT token audience here:
241
+ # https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified, the `endpoint` URL will be used.
218
242
  #
219
243
  # @param [String] new_audience New audience value.
220
244
  def audience= new_audience