google-cloud-pubsub 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ba8847f393a5fc464ab63f9d6bca1a7e501c8457afa477486a9bd9c44e6d126
4
- data.tar.gz: '034684fa844d264673c7e79ea17deeea9edc329de16376863e736a5f0825c256'
3
+ metadata.gz: c1306c932b52a6c12aa2aa1e6ba1100ca90ae78a364ce07d8c5844c517c547f4
4
+ data.tar.gz: f6b9413d4d64cebd698f02b7e7a169da5066c9f05d967432ac69737f1e8d76e5
5
5
  SHA512:
6
- metadata.gz: 8a0e87a57f3fbb1522fd4cf5d93d1c0e03e10ecc5cd2c65b2f0ecfc8aabda230370f6118e9f52c9aadc4763ada09ff6bd0128539fa6469f68d22a327292f3403
7
- data.tar.gz: b18e4d310dbfa486b4b40ed4a6bd657c484c4416517b890bc65889644f928d523b8c447b9b0d3b15980cc80673a9fc2ec3927a6eaff9dd742038f999ac51cee0
6
+ metadata.gz: ebd17aea2e53e2b4fbcaa7b5dd76954fe73aa6eb36402db2014e7d7904df0db022f49a7a2cac574567b9f58c70632f7d4360b12c9a96fed15e1f1f133e3a9df2
7
+ data.tar.gz: a1c0e15330824046f66db7ccb5105b16ee07984c36080338d38302ace2c1c5fded2c3e59ba4979c0d4e63c7becdc425a1b25587fda71508b86492cd03fadf8ba
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 1.5.0 / 2020-03-25
4
+
5
+ #### Features
6
+
7
+ * Add max_duration_per_lease_extension to Subscription#listen and Subscriber
8
+
3
9
  ### 1.4.0 / 2020-03-11
4
10
 
5
11
  #### Features
@@ -104,6 +104,7 @@ module Google
104
104
  # received messages.
105
105
  #
106
106
  # @return [Subscriber] returns self so calls can be chained.
107
+ #
107
108
  def start
108
109
  start_pool = synchronize do
109
110
  @started = true
@@ -129,6 +130,7 @@ module Google
129
130
  # received messages have been processed or released.
130
131
  #
131
132
  # @return [Subscriber] returns self so calls can be chained.
133
+ #
132
134
  def stop
133
135
  stop_pool = synchronize do
134
136
  @started = false
@@ -158,6 +160,7 @@ module Google
158
160
  # subscriber is fully stopped. Default will block indefinitely.
159
161
  #
160
162
  # @return [Subscriber] returns self so calls can be chained.
163
+ #
161
164
  def wait! timeout = nil
162
165
  wait_pool = synchronize do
163
166
  @stream_pool.map do |stream|
@@ -190,6 +193,7 @@ module Google
190
193
  # Whether the subscriber has been started.
191
194
  #
192
195
  # @return [boolean] `true` when started, `false` otherwise.
196
+ #
193
197
  def started?
194
198
  synchronize { @started }
195
199
  end
@@ -198,6 +202,7 @@ module Google
198
202
  # Whether the subscriber has been stopped.
199
203
  #
200
204
  # @return [boolean] `true` when stopped, `false` otherwise.
205
+ #
201
206
  def stopped?
202
207
  synchronize { @stopped }
203
208
  end
@@ -279,6 +284,9 @@ module Google
279
284
 
280
285
  ##
281
286
  # The number of received messages to be collected by subscriber. Default is 1,000.
287
+ #
288
+ # @return [Integer] The maximum number of messages.
289
+ #
282
290
  def max_outstanding_messages
283
291
  @inventory[:max_outstanding_messages]
284
292
  end
@@ -289,6 +297,9 @@ module Google
289
297
 
290
298
  ##
291
299
  # The total byte size of received messages to be collected by subscriber. Default is 100,000,000 (100MB).
300
+ #
301
+ # @return [Integer] The maximum number of bytes.
302
+ #
292
303
  def max_outstanding_bytes
293
304
  @inventory[:max_outstanding_bytes]
294
305
  end
@@ -297,19 +308,33 @@ module Google
297
308
 
298
309
  ##
299
310
  # The number of seconds that received messages can be held awaiting processing. Default is 3,600 (1 hour).
311
+ #
312
+ # @return [Integer] The maximum number of seconds.
313
+ #
300
314
  def max_total_lease_duration
301
315
  @inventory[:max_total_lease_duration]
302
316
  end
303
317
  # @deprecated Use {#max_total_lease_duration}.
304
318
  alias inventory_extension max_total_lease_duration
305
319
 
320
+ ##
321
+ # The maximum amount of time in seconds for a single lease extension attempt. Bounds the delay before a message
322
+ # redelivery if the subscriber fails to extend the deadline. Default is 0 (disabled).
323
+ #
324
+ # @return [Integer] The maximum number of seconds.
325
+ #
326
+ def max_duration_per_lease_extension
327
+ @inventory[:max_duration_per_lease_extension]
328
+ end
329
+
306
330
  ##
307
331
  # @private
308
332
  def stream_inventory
309
333
  {
310
- limit: @inventory[:max_outstanding_messages].fdiv(@streams).ceil,
311
- bytesize: @inventory[:max_outstanding_bytes].fdiv(@streams).ceil,
312
- extension: @inventory[:max_total_lease_duration]
334
+ limit: @inventory[:max_outstanding_messages].fdiv(@streams).ceil,
335
+ bytesize: @inventory[:max_outstanding_bytes].fdiv(@streams).ceil,
336
+ extension: @inventory[:max_total_lease_duration],
337
+ max_duration_per_lease_extension: @inventory[:max_duration_per_lease_extension]
313
338
  }
314
339
  end
315
340
 
@@ -351,6 +376,7 @@ module Google
351
376
  @inventory[:max_outstanding_messages] = Integer(@inventory[:max_outstanding_messages] || 1000)
352
377
  @inventory[:max_outstanding_bytes] = Integer(@inventory[:max_outstanding_bytes] || 100_000_000)
353
378
  @inventory[:max_total_lease_duration] = Integer(@inventory[:max_total_lease_duration] || 3600)
379
+ @inventory[:max_duration_per_lease_extension] = Integer(@inventory[:max_duration_per_lease_extension] || 0)
354
380
  end
355
381
 
356
382
  def default_error_callbacks
@@ -30,14 +30,15 @@ module Google
30
30
 
31
31
  include MonitorMixin
32
32
 
33
- attr_reader :stream, :limit, :bytesize, :extension
33
+ attr_reader :stream, :limit, :bytesize, :extension, :max_duration_per_lease_extension
34
34
 
35
- def initialize stream, limit:, bytesize:, extension:
35
+ def initialize stream, limit:, bytesize:, extension:, max_duration_per_lease_extension:
36
36
  super()
37
37
  @stream = stream
38
38
  @limit = limit
39
39
  @bytesize = bytesize
40
40
  @extension = extension
41
+ @max_duration_per_lease_extension = max_duration_per_lease_extension
41
42
  @inventory = {}
42
43
  @wait_cond = new_cond
43
44
  end
@@ -152,7 +153,9 @@ module Google
152
153
  end
153
154
 
154
155
  def calc_delay
155
- (stream.subscriber.deadline - 3) * rand(0.8..0.9)
156
+ delay = (stream.subscriber.deadline - 3) * rand(0.8..0.9)
157
+ delay = [delay, max_duration_per_lease_extension].min if max_duration_per_lease_extension.positive?
158
+ delay
156
159
  end
157
160
  end
158
161
  end
@@ -699,6 +699,9 @@ module Google
699
699
  # subscriber. Default is 100,000,000 (100MB). (Note: replaces `:bytesize`, which is deprecated.)
700
700
  # * `:max_total_lease_duration` [Integer] The number of seconds that received messages can be held awaiting
701
701
  # processing. Default is 3,600 (1 hour). (Note: replaces `:extension`, which is deprecated.)
702
+ # * `:max_duration_per_lease_extension` [Integer] The maximum amount of time in seconds for a single lease
703
+ # extension attempt. Bounds the delay before a message redelivery if the subscriber fails to extend the
704
+ # deadline. Default is 0 (disabled).
702
705
  # @param [Hash] threads The number of threads to create to handle
703
706
  # concurrent calls by each stream opened by the subscriber. Optional.
704
707
  #
@@ -774,6 +777,25 @@ module Google
774
777
  # # Shut down the subscriber when ready to stop receiving messages.
775
778
  # subscriber.stop.wait!
776
779
  #
780
+ # @example Set the maximum amount of time before redelivery if the subscriber fails to extend the deadline:
781
+ # require "google/cloud/pubsub"
782
+ #
783
+ # pubsub = Google::Cloud::PubSub.new
784
+ #
785
+ # sub = pubsub.subscription "my-topic-sub"
786
+ #
787
+ # subscriber = sub.listen inventory: { max_duration_per_lease_extension: 20 } do |received_message|
788
+ # # Process message very slowly with possibility of failure.
789
+ # process rec_message.data # takes minutes
790
+ # rec_message.acknowledge!
791
+ # end
792
+ #
793
+ # # Start background threads that will call block passed to listen.
794
+ # subscriber.start
795
+ #
796
+ # # Shut down the subscriber when ready to stop receiving messages.
797
+ # subscriber.stop.wait!
798
+ #
777
799
  def listen deadline: nil, message_ordering: nil, streams: nil, inventory: nil, threads: {}, &block
778
800
  ensure_service!
779
801
  deadline ||= self.deadline
@@ -293,6 +293,15 @@ module Google
293
293
  # operations on the subscription. If `expiration_policy` is not set, a
294
294
  # *default policy* with `ttl` of 31 days will be used. The minimum allowed
295
295
  # value for `expiration_policy.ttl` is 1 day.
296
+ # @!attribute [rw] filter
297
+ # @return [String]
298
+ # An expression written in the Cloud Pub/Sub filter language. If non-empty,
299
+ # then only `PubsubMessage`s whose `attributes` field matches the filter are
300
+ # delivered on this subscription. If empty, then no messages are filtered
301
+ # out.
302
+ # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
303
+ # API might be changed in backward-incompatible ways and is not recommended
304
+ # for production use. It is not subject to any SLA or deprecation policy.
296
305
  # @!attribute [rw] dead_letter_policy
297
306
  # @return [Google::Cloud::PubSub::V1::DeadLetterPolicy]
298
307
  # A policy that specifies the conditions for dead lettering messages in
@@ -306,8 +315,41 @@ module Google
306
315
  # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
307
316
  # API might be changed in backward-incompatible ways and is not recommended
308
317
  # for production use. It is not subject to any SLA or deprecation policy.
318
+ # @!attribute [rw] retry_policy
319
+ # @return [Google::Cloud::PubSub::V1::RetryPolicy]
320
+ # A policy that specifies how Cloud Pub/Sub retries message delivery for this
321
+ # subscription.
322
+ #
323
+ # If not set, the default retry policy is applied. This generally implies
324
+ # that messages will be retried as soon as possible for healthy subscribers.
325
+ # RetryPolicy will be triggered on NACKs or acknowledgement deadline
326
+ # exceeded events for a given message.
327
+ # <b>EXPERIMENTAL:</b> This API might be changed in backward-incompatible
328
+ # ways and is not recommended for production use. It is not subject to any
329
+ # SLA or deprecation policy.
309
330
  class Subscription; end
310
331
 
332
+ # A policy that specifies how Cloud Pub/Sub retries message delivery.
333
+ #
334
+ # Retry delay will be exponential based on provided minimum and maximum
335
+ # backoffs. https://en.wikipedia.org/wiki/Exponential_backoff.
336
+ #
337
+ # RetryPolicy will be triggered on NACKs or acknowledgement deadline exceeded
338
+ # events for a given message.
339
+ #
340
+ # Retry Policy is implemented on a best effort basis. At times, the delay
341
+ # between consecutive deliveries may not match the configuration. That is,
342
+ # delay can be more or less than configured backoff.
343
+ # @!attribute [rw] minimum_backoff
344
+ # @return [Google::Protobuf::Duration]
345
+ # The minimum delay between consecutive deliveries of a given message.
346
+ # Value should be between 0 and 600 seconds. Defaults to 10 seconds.
347
+ # @!attribute [rw] maximum_backoff
348
+ # @return [Google::Protobuf::Duration]
349
+ # The maximum delay between consecutive deliveries of a given message.
350
+ # Value should be between 0 and 600 seconds. Defaults to 600 seconds.
351
+ class RetryPolicy; end
352
+
311
353
  # Dead lettering is done on a best effort basis. The same message might be
312
354
  # dead lettered multiple times.
313
355
  #
@@ -110,6 +110,8 @@ module Google
110
110
  end
111
111
 
112
112
  # Returns a fully-qualified topic resource name string.
113
+ # @deprecated Multi-pattern resource names will have unified creation and parsing helper functions.
114
+ # This helper function will be deleted in the next major version.
113
115
  # @param project [String]
114
116
  # @param topic [String]
115
117
  # @return [String]
@@ -678,11 +680,13 @@ module Google
678
680
  # require "google/cloud/pubsub"
679
681
  #
680
682
  # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
681
- # formatted_resource = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
683
+ #
684
+ # # TODO: Initialize `resource`:
685
+ # resource = ''
682
686
  #
683
687
  # # TODO: Initialize `policy`:
684
688
  # policy = {}
685
- # response = publisher_client.set_iam_policy(formatted_resource, policy)
689
+ # response = publisher_client.set_iam_policy(resource, policy)
686
690
 
687
691
  def set_iam_policy \
688
692
  resource,
@@ -720,8 +724,10 @@ module Google
720
724
  # require "google/cloud/pubsub"
721
725
  #
722
726
  # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
723
- # formatted_resource = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
724
- # response = publisher_client.get_iam_policy(formatted_resource)
727
+ #
728
+ # # TODO: Initialize `resource`:
729
+ # resource = ''
730
+ # response = publisher_client.get_iam_policy(resource)
725
731
 
726
732
  def get_iam_policy \
727
733
  resource,
@@ -764,11 +770,13 @@ module Google
764
770
  # require "google/cloud/pubsub"
765
771
  #
766
772
  # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
767
- # formatted_resource = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
773
+ #
774
+ # # TODO: Initialize `resource`:
775
+ # resource = ''
768
776
  #
769
777
  # # TODO: Initialize `permissions`:
770
778
  # permissions = []
771
- # response = publisher_client.test_iam_permissions(formatted_resource, permissions)
779
+ # response = publisher_client.test_iam_permissions(resource, permissions)
772
780
 
773
781
  def test_iam_permissions \
774
782
  resource,
@@ -134,6 +134,8 @@ module Google
134
134
  end
135
135
 
136
136
  # Returns a fully-qualified topic resource name string.
137
+ # @deprecated Multi-pattern resource names will have unified creation and parsing helper functions.
138
+ # This helper function will be deleted in the next major version.
137
139
  # @param project [String]
138
140
  # @param topic [String]
139
141
  # @return [String]
@@ -501,6 +503,14 @@ module Google
501
503
  # value for `expiration_policy.ttl` is 1 day.
502
504
  # A hash of the same form as `Google::Cloud::PubSub::V1::ExpirationPolicy`
503
505
  # can also be provided.
506
+ # @param filter [String]
507
+ # An expression written in the Cloud Pub/Sub filter language. If non-empty,
508
+ # then only `PubsubMessage`s whose `attributes` field matches the filter are
509
+ # delivered on this subscription. If empty, then no messages are filtered
510
+ # out.
511
+ # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
512
+ # API might be changed in backward-incompatible ways and is not recommended
513
+ # for production use. It is not subject to any SLA or deprecation policy.
504
514
  # @param dead_letter_policy [Google::Cloud::PubSub::V1::DeadLetterPolicy | Hash]
505
515
  # A policy that specifies the conditions for dead lettering messages in
506
516
  # this subscription. If dead_letter_policy is not set, dead lettering
@@ -515,6 +525,19 @@ module Google
515
525
  # for production use. It is not subject to any SLA or deprecation policy.
516
526
  # A hash of the same form as `Google::Cloud::PubSub::V1::DeadLetterPolicy`
517
527
  # can also be provided.
528
+ # @param retry_policy [Google::Cloud::PubSub::V1::RetryPolicy | Hash]
529
+ # A policy that specifies how Cloud Pub/Sub retries message delivery for this
530
+ # subscription.
531
+ #
532
+ # If not set, the default retry policy is applied. This generally implies
533
+ # that messages will be retried as soon as possible for healthy subscribers.
534
+ # RetryPolicy will be triggered on NACKs or acknowledgement deadline
535
+ # exceeded events for a given message.
536
+ # <b>EXPERIMENTAL:</b> This API might be changed in backward-incompatible
537
+ # ways and is not recommended for production use. It is not subject to any
538
+ # SLA or deprecation policy.
539
+ # A hash of the same form as `Google::Cloud::PubSub::V1::RetryPolicy`
540
+ # can also be provided.
518
541
  # @param options [Google::Gax::CallOptions]
519
542
  # Overrides the default settings for this call, e.g, timeout,
520
543
  # retries, etc.
@@ -541,7 +564,9 @@ module Google
541
564
  labels: nil,
542
565
  enable_message_ordering: nil,
543
566
  expiration_policy: nil,
567
+ filter: nil,
544
568
  dead_letter_policy: nil,
569
+ retry_policy: nil,
545
570
  options: nil,
546
571
  &block
547
572
  req = {
@@ -554,7 +579,9 @@ module Google
554
579
  labels: labels,
555
580
  enable_message_ordering: enable_message_ordering,
556
581
  expiration_policy: expiration_policy,
557
- dead_letter_policy: dead_letter_policy
582
+ filter: filter,
583
+ dead_letter_policy: dead_letter_policy,
584
+ retry_policy: retry_policy
558
585
  }.delete_if { |_, v| v.nil? }
559
586
  req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::Subscription)
560
587
  @create_subscription.call(req, options, &block)
@@ -1279,11 +1306,13 @@ module Google
1279
1306
  # require "google/cloud/pubsub"
1280
1307
  #
1281
1308
  # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1282
- # formatted_resource = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1309
+ #
1310
+ # # TODO: Initialize `resource`:
1311
+ # resource = ''
1283
1312
  #
1284
1313
  # # TODO: Initialize `policy`:
1285
1314
  # policy = {}
1286
- # response = subscriber_client.set_iam_policy(formatted_resource, policy)
1315
+ # response = subscriber_client.set_iam_policy(resource, policy)
1287
1316
 
1288
1317
  def set_iam_policy \
1289
1318
  resource,
@@ -1321,8 +1350,10 @@ module Google
1321
1350
  # require "google/cloud/pubsub"
1322
1351
  #
1323
1352
  # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1324
- # formatted_resource = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1325
- # response = subscriber_client.get_iam_policy(formatted_resource)
1353
+ #
1354
+ # # TODO: Initialize `resource`:
1355
+ # resource = ''
1356
+ # response = subscriber_client.get_iam_policy(resource)
1326
1357
 
1327
1358
  def get_iam_policy \
1328
1359
  resource,
@@ -1365,11 +1396,13 @@ module Google
1365
1396
  # require "google/cloud/pubsub"
1366
1397
  #
1367
1398
  # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1368
- # formatted_resource = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1399
+ #
1400
+ # # TODO: Initialize `resource`:
1401
+ # resource = ''
1369
1402
  #
1370
1403
  # # TODO: Initialize `permissions`:
1371
1404
  # permissions = []
1372
- # response = subscriber_client.test_iam_permissions(formatted_resource, permissions)
1405
+ # response = subscriber_client.test_iam_permissions(resource, permissions)
1373
1406
 
1374
1407
  def test_iam_permissions \
1375
1408
  resource,
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module PubSub
19
- VERSION = "1.4.0".freeze
19
+ VERSION = "1.5.0".freeze
20
20
  end
21
21
 
22
22
  Pubsub = PubSub unless const_defined? :Pubsub
@@ -83,7 +83,13 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
83
83
  map :labels, :string, :string, 9
84
84
  optional :enable_message_ordering, :bool, 10
85
85
  optional :expiration_policy, :message, 11, "google.pubsub.v1.ExpirationPolicy"
86
+ optional :filter, :string, 12
86
87
  optional :dead_letter_policy, :message, 13, "google.pubsub.v1.DeadLetterPolicy"
88
+ optional :retry_policy, :message, 14, "google.pubsub.v1.RetryPolicy"
89
+ end
90
+ add_message "google.pubsub.v1.RetryPolicy" do
91
+ optional :minimum_backoff, :message, 1, "google.protobuf.Duration"
92
+ optional :maximum_backoff, :message, 2, "google.protobuf.Duration"
87
93
  end
88
94
  add_message "google.pubsub.v1.DeadLetterPolicy" do
89
95
  optional :dead_letter_topic, :string, 1
@@ -223,6 +229,7 @@ module Google::Cloud::PubSub::V1
223
229
  ListTopicSnapshotsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.ListTopicSnapshotsResponse").msgclass
224
230
  DeleteTopicRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DeleteTopicRequest").msgclass
225
231
  Subscription = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.Subscription").msgclass
232
+ RetryPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.RetryPolicy").msgclass
226
233
  DeadLetterPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DeadLetterPolicy").msgclass
227
234
  ExpirationPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.ExpirationPolicy").msgclass
228
235
  PushConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.PushConfig").msgclass
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.4.0
4
+ version: 1.5.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-03-11 00:00:00.000000000 Z
12
+ date: 2020-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby