google-cloud-pubsub 1.9.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +53 -0
  4. data/OVERVIEW.md +26 -58
  5. data/lib/google-cloud-pubsub.rb +14 -13
  6. data/lib/google/cloud/pubsub.rb +15 -18
  7. data/lib/google/cloud/pubsub/async_publisher.rb +2 -3
  8. data/lib/google/cloud/pubsub/credentials.rb +2 -2
  9. data/lib/google/cloud/pubsub/message.rb +1 -1
  10. data/lib/google/cloud/pubsub/project.rb +1 -1
  11. data/lib/google/cloud/pubsub/received_message.rb +4 -4
  12. data/lib/google/cloud/pubsub/service.rb +110 -257
  13. data/lib/google/cloud/pubsub/subscriber.rb +3 -3
  14. data/lib/google/cloud/pubsub/subscriber/stream.rb +1 -2
  15. data/lib/google/cloud/pubsub/subscription.rb +124 -22
  16. data/lib/google/cloud/pubsub/subscription/push_config.rb +55 -31
  17. data/lib/google/cloud/pubsub/topic.rb +50 -15
  18. data/lib/google/cloud/pubsub/version.rb +1 -1
  19. metadata +8 -79
  20. data/lib/google/cloud/pubsub/v1.rb +0 -17
  21. data/lib/google/cloud/pubsub/v1/credentials.rb +0 -41
  22. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +0 -21
  23. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +0 -21
  24. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +0 -21
  25. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -91
  26. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +0 -29
  27. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -222
  28. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -113
  29. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -833
  30. data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +0 -19
  31. data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -928
  32. data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -120
  33. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1466
  34. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -153
  35. data/lib/google/pubsub/v1/pubsub_pb.rb +0 -269
  36. data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -215
@@ -78,7 +78,7 @@ module Google
78
78
  # end
79
79
  # end
80
80
  #
81
- # topic.async_publisher.stop.wait!
81
+ # topic.async_publisher.stop!
82
82
  #
83
83
  def async_publisher
84
84
  @async_publisher
@@ -275,7 +275,10 @@ module Google
275
275
  # 604,800 seconds (7 days) or less than 600 seconds (10 minutes).
276
276
  # Default is 604,800 seconds (7 days).
277
277
  # @param [String] endpoint A URL locating the endpoint to which messages
278
- # should be pushed.
278
+ # should be pushed. The parameters `push_config` and `endpoint` should not both be provided.
279
+ # @param [Google::Cloud::PubSub::Subscription::PushConfig] push_config The configuration for a push delivery
280
+ # endpoint that should contain the endpoint, and can contain authentication data (OIDC token authentication).
281
+ # The parameters `push_config` and `endpoint` should not both be provided.
279
282
  # @param [Hash] labels A hash of user-provided labels associated with
280
283
  # the subscription. You can use these to organize and group your
281
284
  # subscriptions. Label keys and values can be no longer than 63
@@ -320,15 +323,25 @@ module Google
320
323
  # sub = topic.subscribe "my-topic-sub"
321
324
  # sub.name # => "my-topic-sub"
322
325
  #
323
- # @example Wait 2 minutes for acknowledgement and push all to endpoint:
326
+ # @example Wait 2 minutes for acknowledgement:
324
327
  # require "google/cloud/pubsub"
325
328
  #
326
329
  # pubsub = Google::Cloud::PubSub.new
327
330
  #
328
331
  # topic = pubsub.topic "my-topic"
329
332
  # sub = topic.subscribe "my-topic-sub",
330
- # deadline: 120,
331
- # endpoint: "https://example.com/push"
333
+ # deadline: 120
334
+ #
335
+ # @example Configure a push endpoint:
336
+ # require "google/cloud/pubsub"
337
+ #
338
+ # pubsub = Google::Cloud::PubSub.new
339
+ # topic = pubsub.topic "my-topic"
340
+ #
341
+ # push_config = Google::Cloud::PubSub::Subscription::PushConfig.new endpoint: "http://example.net/callback"
342
+ # push_config.set_oidc_token "service-account@example.net", "audience-header-value"
343
+ #
344
+ # sub = topic.subscribe "my-subscription", push_config: push_config
332
345
  #
333
346
  # @example Configure a Dead Letter Queues policy:
334
347
  # require "google/cloud/pubsub"
@@ -361,18 +374,40 @@ module Google
361
374
  # retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
362
375
  # sub = topic.subscribe "my-topic-sub", retry_policy: retry_policy
363
376
  #
364
- def subscribe subscription_name, deadline: nil, retain_acked: false, retention: nil, endpoint: nil, labels: nil,
365
- message_ordering: nil, filter: nil, dead_letter_topic: nil,
366
- dead_letter_max_delivery_attempts: nil, retry_policy: nil
377
+ def subscribe subscription_name,
378
+ deadline: nil,
379
+ retain_acked: false,
380
+ retention: nil,
381
+ endpoint: nil,
382
+ push_config: nil,
383
+ labels: nil,
384
+ message_ordering: nil,
385
+ filter: nil,
386
+ dead_letter_topic: nil,
387
+ dead_letter_max_delivery_attempts: nil,
388
+ retry_policy: nil
367
389
  ensure_service!
368
- options = { deadline: deadline, retain_acked: retain_acked, retention: retention, endpoint: endpoint,
369
- labels: labels, message_ordering: message_ordering, filter: filter,
370
- dead_letter_max_delivery_attempts: dead_letter_max_delivery_attempts }
390
+ if push_config && endpoint
391
+ raise ArgumentError, "endpoint and push_config were both provided. Please provide only one."
392
+ end
393
+ push_config = Google::Cloud::PubSub::Subscription::PushConfig.new endpoint: endpoint if endpoint
394
+
395
+ options = {
396
+ deadline: deadline,
397
+ retain_acked: retain_acked,
398
+ retention: retention,
399
+ labels: labels,
400
+ message_ordering: message_ordering,
401
+ filter: filter,
402
+ dead_letter_max_delivery_attempts: dead_letter_max_delivery_attempts
403
+ }
404
+
371
405
  options[:dead_letter_topic_name] = dead_letter_topic.name if dead_letter_topic
372
406
  if options[:dead_letter_max_delivery_attempts] && !options[:dead_letter_topic_name]
373
407
  # Service error message "3:Invalid resource name given (name=)." does not identify param.
374
408
  raise ArgumentError, "dead_letter_topic is required with dead_letter_max_delivery_attempts"
375
409
  end
410
+ options[:push_config] = push_config.to_grpc if push_config
376
411
  options[:retry_policy] = retry_policy.to_grpc if retry_policy
377
412
  grpc = service.create_subscription name, subscription_name, options
378
413
  Subscription.from_grpc grpc, service
@@ -589,7 +624,7 @@ module Google
589
624
  # end
590
625
  #
591
626
  # # Shut down the publisher when ready to stop publishing messages.
592
- # topic.async_publisher.stop.wait!
627
+ # topic.async_publisher.stop!
593
628
  #
594
629
  # @example A message can be published using a File object:
595
630
  # require "google/cloud/pubsub"
@@ -601,7 +636,7 @@ module Google
601
636
  # topic.publish_async file
602
637
  #
603
638
  # # Shut down the publisher when ready to stop publishing messages.
604
- # topic.async_publisher.stop.wait!
639
+ # topic.async_publisher.stop!
605
640
  #
606
641
  # @example Additionally, a message can be published with attributes:
607
642
  # require "google/cloud/pubsub"
@@ -613,7 +648,7 @@ module Google
613
648
  # foo: :bar, this: :that
614
649
  #
615
650
  # # Shut down the publisher when ready to stop publishing messages.
616
- # topic.async_publisher.stop.wait!
651
+ # topic.async_publisher.stop!
617
652
  #
618
653
  # @example Ordered messages are supported using ordering_key:
619
654
  # require "google/cloud/pubsub"
@@ -630,7 +665,7 @@ module Google
630
665
  # ordering_key: "task-key"
631
666
  #
632
667
  # # Shut down the publisher when ready to stop publishing messages.
633
- # topic.async_publisher.stop.wait!
668
+ # topic.async_publisher.stop!
634
669
  #
635
670
  def publish_async data = nil, attributes = nil, ordering_key: nil, **extra_attrs, &callback
636
671
  ensure_service!
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module PubSub
19
- VERSION = "1.9.0".freeze
19
+ VERSION = "2.2.0".freeze
20
20
  end
21
21
 
22
22
  Pubsub = PubSub unless const_defined? :Pubsub
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-21 00:00:00.000000000 Z
12
+ date: 2020-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -31,82 +31,28 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.2'
34
+ version: '1.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.2'
41
+ version: '1.5'
42
42
  - !ruby/object:Gem::Dependency
43
- name: google-gax
43
+ name: google-cloud-pubsub-v1
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.8'
48
+ version: '0.0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.8'
56
- - !ruby/object:Gem::Dependency
57
- name: googleapis-common-protos
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 1.3.9
63
- - - "<"
64
- - !ruby/object:Gem::Version
65
- version: '2.0'
66
- type: :runtime
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 1.3.9
73
- - - "<"
74
- - !ruby/object:Gem::Version
75
- version: '2.0'
76
- - !ruby/object:Gem::Dependency
77
- name: googleapis-common-protos-types
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 1.0.4
83
- - - "<"
84
- - !ruby/object:Gem::Version
85
- version: '2.0'
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 1.0.4
93
- - - "<"
94
- - !ruby/object:Gem::Version
95
- version: '2.0'
96
- - !ruby/object:Gem::Dependency
97
- name: grpc-google-iam-v1
98
- requirement: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: 0.6.9
103
- type: :runtime
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: 0.6.9
55
+ version: '0.0'
110
56
  - !ruby/object:Gem::Dependency
111
57
  name: autotest-suffix
112
58
  requirement: !ruby/object:Gem::Requirement
@@ -293,24 +239,7 @@ files:
293
239
  - lib/google/cloud/pubsub/subscription/push_config.rb
294
240
  - lib/google/cloud/pubsub/topic.rb
295
241
  - lib/google/cloud/pubsub/topic/list.rb
296
- - lib/google/cloud/pubsub/v1.rb
297
- - lib/google/cloud/pubsub/v1/credentials.rb
298
- - lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb
299
- - lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb
300
- - lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb
301
- - lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb
302
- - lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb
303
- - lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb
304
- - lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb
305
- - lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb
306
- - lib/google/cloud/pubsub/v1/doc/google/type/expr.rb
307
- - lib/google/cloud/pubsub/v1/publisher_client.rb
308
- - lib/google/cloud/pubsub/v1/publisher_client_config.json
309
- - lib/google/cloud/pubsub/v1/subscriber_client.rb
310
- - lib/google/cloud/pubsub/v1/subscriber_client_config.json
311
242
  - lib/google/cloud/pubsub/version.rb
312
- - lib/google/pubsub/v1/pubsub_pb.rb
313
- - lib/google/pubsub/v1/pubsub_services_pb.rb
314
243
  homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-pubsub
315
244
  licenses:
316
245
  - Apache-2.0
@@ -330,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
259
  - !ruby/object:Gem::Version
331
260
  version: '0'
332
261
  requirements: []
333
- rubygems_version: 3.1.3
262
+ rubygems_version: 3.1.4
334
263
  signing_key:
335
264
  specification_version: 4
336
265
  summary: API Client library for Google Cloud Pub/Sub
@@ -1,17 +0,0 @@
1
- # Copyright 2015 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
-
15
-
16
- require "google/cloud/pubsub/v1/publisher_client"
17
- require "google/cloud/pubsub/v1/subscriber_client"
@@ -1,41 +0,0 @@
1
- # Copyright 2020 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
-
15
-
16
- require "googleauth"
17
-
18
- module Google
19
- module Cloud
20
- module PubSub
21
- module V1
22
- class Credentials < Google::Auth::Credentials
23
- SCOPE = ["https://www.googleapis.com/auth/pubsub"].freeze
24
- PATH_ENV_VARS = %w(PUBSUB_CREDENTIALS
25
- PUBSUB_KEYFILE
26
- GOOGLE_CLOUD_CREDENTIALS
27
- GOOGLE_CLOUD_KEYFILE
28
- GCLOUD_KEYFILE)
29
- JSON_ENV_VARS = %w(PUBSUB_CREDENTIALS_JSON
30
- PUBSUB_KEYFILE_JSON
31
- GOOGLE_CLOUD_CREDENTIALS_JSON
32
- GOOGLE_CLOUD_KEYFILE_JSON
33
- GCLOUD_KEYFILE_JSON)
34
- DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
35
- end
36
- end
37
- end
38
-
39
- Pubsub = PubSub unless const_defined? :Pubsub
40
- end
41
- end
@@ -1,21 +0,0 @@
1
- # Copyright 2020 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
-
15
-
16
- module Google
17
- module Iam
18
- module V1
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # Copyright 2020 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
-
15
-
16
- module Google
17
- module Iam
18
- module V1
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # Copyright 2020 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
-
15
-
16
- module Google
17
- module Iam
18
- module V1
19
- end
20
- end
21
- end
@@ -1,91 +0,0 @@
1
- # Copyright 2020 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
-
15
-
16
- module Google
17
- module Protobuf
18
- # A Duration represents a signed, fixed-length span of time represented
19
- # as a count of seconds and fractions of seconds at nanosecond
20
- # resolution. It is independent of any calendar and concepts like "day"
21
- # or "month". It is related to Timestamp in that the difference between
22
- # two Timestamp values is a Duration and it can be added or subtracted
23
- # from a Timestamp. Range is approximately +-10,000 years.
24
- #
25
- # = Examples
26
- #
27
- # Example 1: Compute Duration from two Timestamps in pseudo code.
28
- #
29
- # Timestamp start = ...;
30
- # Timestamp end = ...;
31
- # Duration duration = ...;
32
- #
33
- # duration.seconds = end.seconds - start.seconds;
34
- # duration.nanos = end.nanos - start.nanos;
35
- #
36
- # if (duration.seconds < 0 && duration.nanos > 0) {
37
- # duration.seconds += 1;
38
- # duration.nanos -= 1000000000;
39
- # } else if (durations.seconds > 0 && duration.nanos < 0) {
40
- # duration.seconds -= 1;
41
- # duration.nanos += 1000000000;
42
- # }
43
- #
44
- # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
45
- #
46
- # Timestamp start = ...;
47
- # Duration duration = ...;
48
- # Timestamp end = ...;
49
- #
50
- # end.seconds = start.seconds + duration.seconds;
51
- # end.nanos = start.nanos + duration.nanos;
52
- #
53
- # if (end.nanos < 0) {
54
- # end.seconds -= 1;
55
- # end.nanos += 1000000000;
56
- # } else if (end.nanos >= 1000000000) {
57
- # end.seconds += 1;
58
- # end.nanos -= 1000000000;
59
- # }
60
- #
61
- # Example 3: Compute Duration from datetime.timedelta in Python.
62
- #
63
- # td = datetime.timedelta(days=3, minutes=10)
64
- # duration = Duration()
65
- # duration.FromTimedelta(td)
66
- #
67
- # = JSON Mapping
68
- #
69
- # In JSON format, the Duration type is encoded as a string rather than an
70
- # object, where the string ends in the suffix "s" (indicating seconds) and
71
- # is preceded by the number of seconds, with nanoseconds expressed as
72
- # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
73
- # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
74
- # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
75
- # microsecond should be expressed in JSON format as "3.000001s".
76
- # @!attribute [rw] seconds
77
- # @return [Integer]
78
- # Signed seconds of the span of time. Must be from -315,576,000,000
79
- # to +315,576,000,000 inclusive. Note: these bounds are computed from:
80
- # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
81
- # @!attribute [rw] nanos
82
- # @return [Integer]
83
- # Signed fractions of a second at nanosecond resolution of the span
84
- # of time. Durations less than one second are represented with a 0
85
- # `seconds` field and a positive or negative `nanos` field. For durations
86
- # of one second or more, a non-zero value for the `nanos` field must be
87
- # of the same sign as the `seconds` field. Must be from -999,999,999
88
- # to +999,999,999 inclusive.
89
- class Duration; end
90
- end
91
- end