google-cloud-pubsub 2.1.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -0
- data/CONTRIBUTING.md +2 -2
- data/LOGGING.md +1 -1
- data/lib/google/cloud/pubsub/async_publisher.rb +9 -5
- data/lib/google/cloud/pubsub/async_publisher/batch.rb +2 -1
- data/lib/google/cloud/pubsub/credentials.rb +1 -1
- data/lib/google/cloud/pubsub/policy.rb +3 -2
- data/lib/google/cloud/pubsub/project.rb +24 -7
- data/lib/google/cloud/pubsub/retry_policy.rb +2 -4
- data/lib/google/cloud/pubsub/service.rb +4 -1
- data/lib/google/cloud/pubsub/snapshot.rb +4 -2
- data/lib/google/cloud/pubsub/snapshot/list.rb +2 -2
- data/lib/google/cloud/pubsub/subscriber.rb +21 -3
- data/lib/google/cloud/pubsub/subscriber/inventory.rb +10 -3
- data/lib/google/cloud/pubsub/subscriber/stream.rb +3 -3
- data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +6 -7
- data/lib/google/cloud/pubsub/subscription.rb +83 -28
- data/lib/google/cloud/pubsub/subscription/list.rb +2 -2
- data/lib/google/cloud/pubsub/topic.rb +23 -16
- data/lib/google/cloud/pubsub/topic/list.rb +2 -2
- data/lib/google/cloud/pubsub/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4148f77602c7b9031ed772a14735b25414034684472928fb5244a3c07c2c080
|
4
|
+
data.tar.gz: 247fd6d4697c8e4f04858487441a3552f30ebe3010720861a1e2c9e8198de219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c926ed2d0bca88e81a0545e86ca4fdd916df9d24f1108e4e74cf9140c0a835b79fb6fc207074d62a920de0958e69071235d0c8874970aae9db3657e24c36b2e1
|
7
|
+
data.tar.gz: 3f719066bf2ffc015b88dd0ffc5f13c38d853c2e54603daa6190905420a87b4aeb9372e4d1bcb37d68863ac38151d147d465ec3891333608718ede84123dca92
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,44 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 2.4.0 / 2021-03-10
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0
|
8
|
+
|
9
|
+
### 2.3.2 / 2021-02-08
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* Fix project option in Project#topic and Project#subscription
|
14
|
+
* Ensure that project option is used when skip_lookup is false.
|
15
|
+
* Improve documentation of topic_name, subscription_name and snapshot_name.
|
16
|
+
|
17
|
+
### 2.3.1 / 2021-01-13
|
18
|
+
|
19
|
+
#### Bug Fixes
|
20
|
+
|
21
|
+
* Update Subscription#retry_policy=
|
22
|
+
* Remove conditional RPC to fetch full resource before update.
|
23
|
+
|
24
|
+
### 2.3.0 / 2020-11-18
|
25
|
+
|
26
|
+
#### Features
|
27
|
+
|
28
|
+
* Add inventory.use_legacy_flow_control to listen options
|
29
|
+
* Add inventory.use_legacy_flow_control to Subscription#listen options
|
30
|
+
* Add Subscriber#use_legacy_flow_control?
|
31
|
+
|
32
|
+
#### Documentation
|
33
|
+
|
34
|
+
* Remove EXPERIMENTAL label from RetryPolicy docs
|
35
|
+
|
36
|
+
### 2.2.0 / 2020-11-11
|
37
|
+
|
38
|
+
#### Features
|
39
|
+
|
40
|
+
* Add Subscription#remove_dead_letter_policy
|
41
|
+
|
3
42
|
### 2.1.1 / 2020-10-26
|
4
43
|
|
5
44
|
#### Documentation
|
data/CONTRIBUTING.md
CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
|
|
24
24
|
In order to use the google-cloud-pubsub console and run the project's tests,
|
25
25
|
there is a small amount of setup:
|
26
26
|
|
27
|
-
1. Install Ruby. google-cloud-pubsub requires Ruby 2.
|
27
|
+
1. Install Ruby. google-cloud-pubsub requires Ruby 2.5+. You may choose to
|
28
28
|
manage your Ruby and gem installations with [RVM](https://rvm.io/),
|
29
29
|
[rbenv](https://github.com/rbenv/rbenv), or
|
30
30
|
[chruby](https://github.com/postmodern/chruby).
|
@@ -45,7 +45,7 @@ there is a small amount of setup:
|
|
45
45
|
|
46
46
|
```sh
|
47
47
|
$ cd google-cloud-pubsub/
|
48
|
-
$ bundle
|
48
|
+
$ bundle install
|
49
49
|
```
|
50
50
|
|
51
51
|
## Console
|
data/LOGGING.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
To enable logging for this library, set the logger for the underlying
|
4
4
|
[gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
|
5
5
|
that you set may be a Ruby stdlib
|
6
|
-
[`Logger`](https://ruby-doc.org/stdlib
|
6
|
+
[`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as
|
7
7
|
shown below, or a
|
8
8
|
[`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
9
9
|
that will write logs to [Stackdriver
|
@@ -44,8 +44,8 @@ module Google
|
|
44
44
|
#
|
45
45
|
# topic.async_publisher.stop!
|
46
46
|
#
|
47
|
-
# @attr_reader [String] topic_name The name of the topic the messages are published to.
|
48
|
-
#
|
47
|
+
# @attr_reader [String] topic_name The name of the topic the messages are published to. The value is a
|
48
|
+
# fully-qualified topic name in the form `projects/{project_id}/topics/{topic_id}`.
|
49
49
|
# @attr_reader [Integer] max_bytes The maximum size of messages to be collected before the batch is published.
|
50
50
|
# Default is 1,000,000 (1MB).
|
51
51
|
# @attr_reader [Integer] max_messages The maximum number of messages to be collected before the batch is
|
@@ -59,8 +59,12 @@ module Google
|
|
59
59
|
class AsyncPublisher
|
60
60
|
include MonitorMixin
|
61
61
|
|
62
|
-
attr_reader :topic_name
|
63
|
-
|
62
|
+
attr_reader :topic_name
|
63
|
+
attr_reader :max_bytes
|
64
|
+
attr_reader :max_messages
|
65
|
+
attr_reader :interval
|
66
|
+
attr_reader :publish_threads
|
67
|
+
attr_reader :callback_threads
|
64
68
|
##
|
65
69
|
# @private Implementation accessors
|
66
70
|
attr_reader :service, :batch, :publish_thread_pool,
|
@@ -303,7 +307,7 @@ module Google
|
|
303
307
|
|
304
308
|
def publish_batches! stop: nil
|
305
309
|
@batches.reject! { |_ordering_key, batch| batch.empty? }
|
306
|
-
@batches.
|
310
|
+
@batches.each_value do |batch|
|
307
311
|
ready = batch.publish! stop: stop
|
308
312
|
publish_batch_async @topic_name, batch if ready
|
309
313
|
end
|
@@ -68,7 +68,8 @@ module Google
|
|
68
68
|
# end
|
69
69
|
#
|
70
70
|
class Policy
|
71
|
-
attr_reader :etag
|
71
|
+
attr_reader :etag
|
72
|
+
attr_reader :roles
|
72
73
|
|
73
74
|
##
|
74
75
|
# @private Creates a Policy object.
|
@@ -167,7 +168,7 @@ module Google
|
|
167
168
|
role: role_name,
|
168
169
|
members: roles[role_name]
|
169
170
|
)
|
170
|
-
end
|
171
|
+
end.compact
|
171
172
|
)
|
172
173
|
end
|
173
174
|
|
@@ -75,10 +75,14 @@ module Google
|
|
75
75
|
##
|
76
76
|
# Retrieves topic by name.
|
77
77
|
#
|
78
|
-
# @param [String] topic_name Name of a topic.
|
78
|
+
# @param [String] topic_name Name of a topic. The value can be a simple
|
79
|
+
# topic ID (relative name), in which case the current project ID will
|
80
|
+
# be supplied, or a fully-qualified topic name in the form
|
81
|
+
# `projects/{project_id}/topics/{topic_id}`.
|
79
82
|
# @param [String] project If the topic belongs to a project other than
|
80
83
|
# the one currently connected to, the alternate project ID can be
|
81
|
-
# specified here. Optional.
|
84
|
+
# specified here. Optional. Not used if a fully-qualified topic name
|
85
|
+
# is provided for `topic_name`.
|
82
86
|
# @param [Boolean] skip_lookup Optionally create a {Topic} object
|
83
87
|
# without verifying the topic resource exists on the Pub/Sub service.
|
84
88
|
# Calls made on this object will raise errors if the topic resource
|
@@ -147,7 +151,7 @@ module Google
|
|
147
151
|
ensure_service!
|
148
152
|
options = { project: project }
|
149
153
|
return Topic.from_name topic_name, service, options if skip_lookup
|
150
|
-
grpc = service.get_topic topic_name
|
154
|
+
grpc = service.get_topic topic_name, options
|
151
155
|
Topic.from_grpc grpc, service, async: async
|
152
156
|
rescue Google::Cloud::NotFoundError
|
153
157
|
nil
|
@@ -158,7 +162,16 @@ module Google
|
|
158
162
|
##
|
159
163
|
# Creates a new topic.
|
160
164
|
#
|
161
|
-
# @param [String] topic_name Name of a topic.
|
165
|
+
# @param [String] topic_name Name of a topic. Required.
|
166
|
+
# The value can be a simple topic ID (relative name), in which
|
167
|
+
# case the current project ID will be supplied, or a fully-qualified
|
168
|
+
# topic name in the form `projects/{project_id}/topics/{topic_id}`.
|
169
|
+
#
|
170
|
+
# The topic ID (relative name) must start with a letter, and
|
171
|
+
# contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
|
172
|
+
# underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
|
173
|
+
# signs (`%`). It must be between 3 and 255 characters in length, and
|
174
|
+
# it must not start with `goog`.
|
162
175
|
# @param [Hash] labels A hash of user-provided labels associated with
|
163
176
|
# the topic. You can use these to organize and group your topics.
|
164
177
|
# Label keys and values can be no longer than 63 characters, can only
|
@@ -250,10 +263,14 @@ module Google
|
|
250
263
|
##
|
251
264
|
# Retrieves subscription by name.
|
252
265
|
#
|
253
|
-
# @param [String] subscription_name Name of a subscription.
|
266
|
+
# @param [String] subscription_name Name of a subscription. The value can
|
267
|
+
# be a simple subscription ID, in which case the current project ID
|
268
|
+
# will be supplied, or a fully-qualified subscription name in the form
|
269
|
+
# `projects/{project_id}/subscriptions/{subscription_id}`.
|
254
270
|
# @param [String] project If the subscription belongs to a project other
|
255
271
|
# than the one currently connected to, the alternate project ID can be
|
256
|
-
# specified here.
|
272
|
+
# specified here. Not used if a fully-qualified subscription name is
|
273
|
+
# provided for `subscription_name`.
|
257
274
|
# @param [Boolean] skip_lookup Optionally create a {Subscription} object
|
258
275
|
# without verifying the subscription resource exists on the Pub/Sub
|
259
276
|
# service. Calls made on this object will raise errors if the service
|
@@ -283,7 +300,7 @@ module Google
|
|
283
300
|
ensure_service!
|
284
301
|
options = { project: project }
|
285
302
|
return Subscription.from_name subscription_name, service, options if skip_lookup
|
286
|
-
grpc = service.get_subscription subscription_name
|
303
|
+
grpc = service.get_subscription subscription_name, options
|
287
304
|
Subscription.from_grpc grpc, service
|
288
305
|
rescue Google::Cloud::NotFoundError
|
289
306
|
nil
|
@@ -31,9 +31,6 @@ module Google
|
|
31
31
|
# Retry Policy is implemented on a best effort basis. At times, the delay between consecutive deliveries may not
|
32
32
|
# match the configuration. That is, delay can be more or less than configured backoff.
|
33
33
|
#
|
34
|
-
# **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for production
|
35
|
-
# use. It is not subject to any SLA or deprecation policy.
|
36
|
-
#
|
37
34
|
# @attr [Numeric] minimum_backoff The minimum delay between consecutive deliveries of a given message. Value
|
38
35
|
# should be between 0 and 600 seconds. The default value is 10 seconds.
|
39
36
|
# @attr [Numeric] maximum_backoff The maximum delay between consecutive deliveries of a given message. Value
|
@@ -52,7 +49,8 @@ module Google
|
|
52
49
|
# sub.retry_policy.maximum_backoff #=> 300
|
53
50
|
#
|
54
51
|
class RetryPolicy
|
55
|
-
attr_reader :minimum_backoff
|
52
|
+
attr_reader :minimum_backoff
|
53
|
+
attr_reader :maximum_backoff
|
56
54
|
|
57
55
|
##
|
58
56
|
# Creates a new, immutable RetryPolicy value object.
|
@@ -26,7 +26,10 @@ module Google
|
|
26
26
|
##
|
27
27
|
# @private Represents the Pub/Sub service API, including IAM mixins.
|
28
28
|
class Service
|
29
|
-
attr_accessor :project
|
29
|
+
attr_accessor :project
|
30
|
+
attr_accessor :credentials
|
31
|
+
attr_accessor :host
|
32
|
+
attr_accessor :timeout
|
30
33
|
###
|
31
34
|
# The same client_id is used across all streaming pull connections that are created by this client. This is
|
32
35
|
# intentional, as it indicates to the server that any guarantees, such as message ordering, made for a stream
|
@@ -58,8 +58,10 @@ module Google
|
|
58
58
|
end
|
59
59
|
|
60
60
|
##
|
61
|
-
# The name of the snapshot.
|
62
|
-
#
|
61
|
+
# The name of the snapshot.
|
62
|
+
#
|
63
|
+
# @return [String] A fully-qualified snapshot name in the form
|
64
|
+
# `projects/{project_id}/snapshots/{snapshot_id}`.
|
63
65
|
def name
|
64
66
|
@grpc.name
|
65
67
|
end
|
@@ -125,12 +125,12 @@ module Google
|
|
125
125
|
# puts snapshot.name
|
126
126
|
# end
|
127
127
|
#
|
128
|
-
def all request_limit: nil
|
128
|
+
def all request_limit: nil, &block
|
129
129
|
request_limit = request_limit.to_i if request_limit
|
130
130
|
return enum_for :all, request_limit: request_limit unless block_given?
|
131
131
|
results = self
|
132
132
|
loop do
|
133
|
-
results.each
|
133
|
+
results.each(&block)
|
134
134
|
if request_limit
|
135
135
|
request_limit -= 1
|
136
136
|
break if request_limit.negative?
|
@@ -64,8 +64,13 @@ module Google
|
|
64
64
|
class Subscriber
|
65
65
|
include MonitorMixin
|
66
66
|
|
67
|
-
attr_reader :subscription_name
|
68
|
-
|
67
|
+
attr_reader :subscription_name
|
68
|
+
attr_reader :callback
|
69
|
+
attr_reader :deadline
|
70
|
+
attr_reader :streams
|
71
|
+
attr_reader :message_ordering
|
72
|
+
attr_reader :callback_threads
|
73
|
+
attr_reader :push_threads
|
69
74
|
|
70
75
|
##
|
71
76
|
# @private Implementation attributes.
|
@@ -306,6 +311,17 @@ module Google
|
|
306
311
|
# @deprecated Use {#max_outstanding_bytes}.
|
307
312
|
alias inventory_bytesize max_outstanding_bytes
|
308
313
|
|
314
|
+
##
|
315
|
+
# Whether to enforce flow control at the client side only or to enforce it at both the client and
|
316
|
+
# the server. For more details about flow control see https://cloud.google.com/pubsub/docs/pull#config.
|
317
|
+
#
|
318
|
+
# @return [Boolean] `true` when only client side flow control is enforced, `false` when both client and
|
319
|
+
# server side flow control are enforced.
|
320
|
+
#
|
321
|
+
def use_legacy_flow_control?
|
322
|
+
@inventory[:use_legacy_flow_control]
|
323
|
+
end
|
324
|
+
|
309
325
|
##
|
310
326
|
# The number of seconds that received messages can be held awaiting processing. Default is 3,600 (1 hour).
|
311
327
|
#
|
@@ -334,7 +350,8 @@ module Google
|
|
334
350
|
limit: @inventory[:max_outstanding_messages].fdiv(@streams).ceil,
|
335
351
|
bytesize: @inventory[:max_outstanding_bytes].fdiv(@streams).ceil,
|
336
352
|
extension: @inventory[:max_total_lease_duration],
|
337
|
-
max_duration_per_lease_extension: @inventory[:max_duration_per_lease_extension]
|
353
|
+
max_duration_per_lease_extension: @inventory[:max_duration_per_lease_extension],
|
354
|
+
use_legacy_flow_control: @inventory[:use_legacy_flow_control]
|
338
355
|
}
|
339
356
|
end
|
340
357
|
|
@@ -377,6 +394,7 @@ module Google
|
|
377
394
|
@inventory[:max_outstanding_bytes] = Integer(@inventory[:max_outstanding_bytes] || 100_000_000)
|
378
395
|
@inventory[:max_total_lease_duration] = Integer(@inventory[:max_total_lease_duration] || 3600)
|
379
396
|
@inventory[:max_duration_per_lease_extension] = Integer(@inventory[:max_duration_per_lease_extension] || 0)
|
397
|
+
@inventory[:use_legacy_flow_control] = @inventory[:use_legacy_flow_control] || false
|
380
398
|
end
|
381
399
|
|
382
400
|
def default_error_callbacks
|
@@ -30,15 +30,22 @@ module Google
|
|
30
30
|
|
31
31
|
include MonitorMixin
|
32
32
|
|
33
|
-
attr_reader :stream
|
34
|
-
|
35
|
-
|
33
|
+
attr_reader :stream
|
34
|
+
attr_reader :limit
|
35
|
+
attr_reader :bytesize
|
36
|
+
attr_reader :extension
|
37
|
+
attr_reader :max_duration_per_lease_extension
|
38
|
+
attr_reader :use_legacy_flow_control
|
39
|
+
|
40
|
+
def initialize stream, limit:, bytesize:, extension:, max_duration_per_lease_extension:,
|
41
|
+
use_legacy_flow_control:
|
36
42
|
super()
|
37
43
|
@stream = stream
|
38
44
|
@limit = limit
|
39
45
|
@bytesize = bytesize
|
40
46
|
@extension = extension
|
41
47
|
@max_duration_per_lease_extension = max_duration_per_lease_extension
|
48
|
+
@use_legacy_flow_control = use_legacy_flow_control
|
42
49
|
@inventory = {}
|
43
50
|
@wait_cond = new_cond
|
44
51
|
end
|
@@ -58,7 +58,7 @@ module Google
|
|
58
58
|
@paused = nil
|
59
59
|
@pause_cond = new_cond
|
60
60
|
|
61
|
-
@inventory = Inventory.new self,
|
61
|
+
@inventory = Inventory.new self, **@subscriber.stream_inventory
|
62
62
|
|
63
63
|
@sequencer = Sequencer.new(&method(:perform_callback_async)) if subscriber.message_ordering
|
64
64
|
|
@@ -363,8 +363,8 @@ module Google
|
|
363
363
|
req.modify_deadline_ack_ids += @inventory.ack_ids
|
364
364
|
req.modify_deadline_seconds += @inventory.ack_ids.map { @subscriber.deadline }
|
365
365
|
req.client_id = @subscriber.service.client_id
|
366
|
-
req.max_outstanding_messages = @inventory.limit
|
367
|
-
req.max_outstanding_bytes = @inventory.bytesize
|
366
|
+
req.max_outstanding_messages = @inventory.use_legacy_flow_control ? 0 : @inventory.limit
|
367
|
+
req.max_outstanding_bytes = @inventory.use_legacy_flow_control ? 0 : @inventory.bytesize
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
@@ -25,7 +25,8 @@ module Google
|
|
25
25
|
class TimedUnaryBuffer
|
26
26
|
include MonitorMixin
|
27
27
|
|
28
|
-
attr_reader :max_bytes
|
28
|
+
attr_reader :max_bytes
|
29
|
+
attr_reader :interval
|
29
30
|
|
30
31
|
def initialize subscriber, max_bytes: 500_000, interval: 1.0
|
31
32
|
super() # to init MonitorMixin
|
@@ -138,7 +139,7 @@ module Google
|
|
138
139
|
end
|
139
140
|
|
140
141
|
groups = prev_reg.each_pair.group_by { |_ack_id, delay| delay }
|
141
|
-
req_hash =
|
142
|
+
req_hash = groups.transform_values { |v| v.map(&:first) }
|
142
143
|
|
143
144
|
requests = { acknowledge: [] }
|
144
145
|
ack_ids = Array(req_hash.delete(:ack)) # ack has no deadline set
|
@@ -215,11 +216,9 @@ module Google
|
|
215
216
|
|
216
217
|
def add_future pool
|
217
218
|
Concurrent::Promises.future_on pool do
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
error! e
|
222
|
-
end
|
219
|
+
yield
|
220
|
+
rescue StandardError => e
|
221
|
+
error! e
|
223
222
|
end
|
224
223
|
end
|
225
224
|
end
|
@@ -77,7 +77,9 @@ module Google
|
|
77
77
|
##
|
78
78
|
# The name of the subscription.
|
79
79
|
#
|
80
|
-
# @return [String]
|
80
|
+
# @return [String] A fully-qualified subscription name in the form
|
81
|
+
# `projects/{project_id}/subscriptions/{subscription_id}`.
|
82
|
+
#
|
81
83
|
def name
|
82
84
|
return @resource_name if reference?
|
83
85
|
@grpc.name
|
@@ -330,7 +332,7 @@ module Google
|
|
330
332
|
# If {#expires_in=} is not set, a *default* value of of 31 days will be
|
331
333
|
# used. The minimum allowed value is 1 day.
|
332
334
|
#
|
333
|
-
# Makes an API call to retrieve the value when called on a
|
335
|
+
# Makes an API call to retrieve the expires_in value when called on a
|
334
336
|
# reference object. See {#reference?}.
|
335
337
|
#
|
336
338
|
# @return [Numeric, nil] The expiration duration, or `nil` if unset.
|
@@ -365,6 +367,9 @@ module Google
|
|
365
367
|
# `attributes` field matches the filter are delivered on this subscription. If empty, then no messages are
|
366
368
|
# filtered out.
|
367
369
|
#
|
370
|
+
# Makes an API call to retrieve the filter value when called on a reference
|
371
|
+
# object. See {#reference?}.
|
372
|
+
#
|
368
373
|
# @return [String] The frozen filter string.
|
369
374
|
#
|
370
375
|
def filter
|
@@ -377,8 +382,8 @@ module Google
|
|
377
382
|
# otherwise `nil`. Dead lettering is done on a best effort basis. The same message might be dead lettered
|
378
383
|
# multiple times.
|
379
384
|
#
|
380
|
-
# See also {#dead_letter_topic=}, {#dead_letter_max_delivery_attempts=}
|
381
|
-
# {#
|
385
|
+
# See also {#dead_letter_topic=}, {#dead_letter_max_delivery_attempts=}, {#dead_letter_max_delivery_attempts}
|
386
|
+
# and {#remove_dead_letter_policy}.
|
382
387
|
#
|
383
388
|
# Makes an API call to retrieve the topic name when called on a reference object. See {#reference?}.
|
384
389
|
#
|
@@ -409,7 +414,11 @@ module Google
|
|
409
414
|
# The operation will fail if the topic does not exist. Users should ensure that there is a subscription attached
|
410
415
|
# to this topic since messages published to a topic with no subscriptions are lost.
|
411
416
|
#
|
412
|
-
#
|
417
|
+
# Makes an API call to retrieve the dead_letter_policy value when called on a
|
418
|
+
# reference object. See {#reference?}.
|
419
|
+
#
|
420
|
+
# See also {#dead_letter_topic}, {#dead_letter_max_delivery_attempts=}, {#dead_letter_max_delivery_attempts}
|
421
|
+
# and {#remove_dead_letter_policy}.
|
413
422
|
#
|
414
423
|
# @param [Topic] new_dead_letter_topic The topic to which dead letter messages for the subscription should be
|
415
424
|
# published.
|
@@ -441,14 +450,15 @@ module Google
|
|
441
450
|
# acknowledgement deadline has been exceeded for the message). A NACK is any call to ModifyAckDeadline with a 0
|
442
451
|
# deadline. Note that client libraries may automatically extend ack_deadlines.
|
443
452
|
#
|
444
|
-
# This field will be honored on a best effort basis. If this parameter is 0
|
453
|
+
# This field will be honored on a best effort basis. If this parameter is `nil` or `0`, a default value of `5`
|
454
|
+
# is used.
|
445
455
|
#
|
446
|
-
# See also {#dead_letter_max_delivery_attempts=}, {#dead_letter_topic=}
|
456
|
+
# See also {#dead_letter_max_delivery_attempts=}, {#dead_letter_topic=}, {#dead_letter_topic}
|
457
|
+
# and {#remove_dead_letter_policy}.
|
447
458
|
#
|
448
|
-
# Makes an API call to retrieve the
|
459
|
+
# Makes an API call to retrieve the dead_letter_policy when called on a reference object. See {#reference?}.
|
449
460
|
#
|
450
|
-
# @return [Integer, nil] A value between 5 and 100
|
451
|
-
# value is 0, a default value of 5 is used.
|
461
|
+
# @return [Integer, nil] A value between `5` and `100`, or `nil` if no dead letter policy is configured.
|
452
462
|
#
|
453
463
|
# @example
|
454
464
|
# require "google/cloud/pubsub"
|
@@ -475,10 +485,15 @@ module Google
|
|
475
485
|
#
|
476
486
|
# This field will be honored on a best effort basis. If this parameter is 0, a default value of 5 is used.
|
477
487
|
#
|
478
|
-
#
|
488
|
+
# Makes an API call to retrieve the dead_letter_policy when called on a reference object. See {#reference?}.
|
489
|
+
#
|
490
|
+
# The dead letter topic must be set first. See {#dead_letter_topic=}, {#dead_letter_topic} and
|
491
|
+
# {#remove_dead_letter_policy}.
|
479
492
|
#
|
480
|
-
# @param [Integer] new_dead_letter_max_delivery_attempts A value between 5 and 100. If this parameter is
|
481
|
-
# default value of 5 is used.
|
493
|
+
# @param [Integer, nil] new_dead_letter_max_delivery_attempts A value between 5 and 100. If this parameter is
|
494
|
+
# `nil` or `0`, a default value of 5 is used.
|
495
|
+
#
|
496
|
+
# @raise [ArgumentError] if the dead letter topic has not been set. See {#dead_letter_topic=}.
|
482
497
|
#
|
483
498
|
# @example
|
484
499
|
# require "google/cloud/pubsub"
|
@@ -503,14 +518,48 @@ module Google
|
|
503
518
|
@resource_name = nil
|
504
519
|
end
|
505
520
|
|
521
|
+
##
|
522
|
+
# Removes an existing dead letter policy. A dead letter policy specifies the conditions for dead lettering
|
523
|
+
# messages in the subscription. If a dead letter policy is not set, dead lettering is disabled.
|
524
|
+
#
|
525
|
+
# Makes an API call to retrieve the dead_letter_policy when called on a reference object. See {#reference?}.
|
526
|
+
#
|
527
|
+
# See {#dead_letter_topic}, {#dead_letter_topic=}, {#dead_letter_max_delivery_attempts} and
|
528
|
+
# {#dead_letter_max_delivery_attempts=}.
|
529
|
+
#
|
530
|
+
# @return [Boolean] `true` if an existing dead letter policy was removed, `false` if no existing dead letter
|
531
|
+
# policy was present.
|
532
|
+
#
|
533
|
+
# @example
|
534
|
+
# require "google/cloud/pubsub"
|
535
|
+
#
|
536
|
+
# pubsub = Google::Cloud::PubSub.new
|
537
|
+
#
|
538
|
+
# sub = pubsub.subscription "my-topic-sub"
|
539
|
+
#
|
540
|
+
# sub.dead_letter_topic.name #=> "projects/my-project/topics/my-dead-letter-topic"
|
541
|
+
# sub.dead_letter_max_delivery_attempts #=> 10
|
542
|
+
#
|
543
|
+
# sub.remove_dead_letter_policy
|
544
|
+
#
|
545
|
+
# sub.dead_letter_topic #=> nil
|
546
|
+
# sub.dead_letter_max_delivery_attempts #=> nil
|
547
|
+
#
|
548
|
+
def remove_dead_letter_policy
|
549
|
+
ensure_grpc!
|
550
|
+
return false if @grpc.dead_letter_policy.nil?
|
551
|
+
update_grpc = Google::Cloud::PubSub::V1::Subscription.new name: name, dead_letter_policy: nil
|
552
|
+
@grpc = service.update_subscription update_grpc, :dead_letter_policy
|
553
|
+
true
|
554
|
+
end
|
555
|
+
|
506
556
|
##
|
507
557
|
# A policy that specifies how Cloud Pub/Sub retries message delivery for this subscription. If `nil`, the
|
508
558
|
# default retry policy is applied. This generally implies that messages will be retried as soon as possible
|
509
559
|
# for healthy subscribers. Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events
|
510
560
|
# for a given message.
|
511
561
|
#
|
512
|
-
#
|
513
|
-
# production use. It is not subject to any SLA or deprecation policy.
|
562
|
+
# Makes an API call to retrieve the retry_policy when called on a reference object. See {#reference?}.
|
514
563
|
#
|
515
564
|
# @return [RetryPolicy, nil] The retry policy for the subscription, or `nil`.
|
516
565
|
#
|
@@ -538,9 +587,6 @@ module Google
|
|
538
587
|
# for healthy subscribers. Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events
|
539
588
|
# for a given message.
|
540
589
|
#
|
541
|
-
# **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
|
542
|
-
# production use. It is not subject to any SLA or deprecation policy.
|
543
|
-
#
|
544
590
|
# @param [RetryPolicy, nil] new_retry_policy A new retry policy for the subscription, or `nil`.
|
545
591
|
#
|
546
592
|
# @example
|
@@ -556,10 +602,11 @@ module Google
|
|
556
602
|
# sub.retry_policy.maximum_backoff #=> 300
|
557
603
|
#
|
558
604
|
def retry_policy= new_retry_policy
|
559
|
-
|
605
|
+
ensure_service!
|
560
606
|
new_retry_policy = new_retry_policy.to_grpc if new_retry_policy
|
561
607
|
update_grpc = Google::Cloud::PubSub::V1::Subscription.new name: name, retry_policy: new_retry_policy
|
562
608
|
@grpc = service.update_subscription update_grpc, :retry_policy
|
609
|
+
@resource_name = nil
|
563
610
|
end
|
564
611
|
|
565
612
|
##
|
@@ -591,7 +638,7 @@ module Google
|
|
591
638
|
#
|
592
639
|
# See {Topic#subscribe} and {#detach}.
|
593
640
|
#
|
594
|
-
# Makes an API call to retrieve the value when called on a
|
641
|
+
# Makes an API call to retrieve the detached value when called on a
|
595
642
|
# reference object. See {#reference?}.
|
596
643
|
#
|
597
644
|
# @return [Boolean]
|
@@ -832,6 +879,9 @@ module Google
|
|
832
879
|
# Default is 1,000. (Note: replaces `:limit`, which is deprecated.)
|
833
880
|
# * `:max_outstanding_bytes` [Integer] The total byte size of received messages to be collected by
|
834
881
|
# subscriber. Default is 100,000,000 (100MB). (Note: replaces `:bytesize`, which is deprecated.)
|
882
|
+
# * `:use_legacy_flow_control` [Boolean] Disables enforcing flow control settings at the Cloud PubSub
|
883
|
+
# server and the less accurate method of only enforcing flow control at the client side is used instead.
|
884
|
+
# Default is false.
|
835
885
|
# * `:max_total_lease_duration` [Integer] The number of seconds that received messages can be held awaiting
|
836
886
|
# processing. Default is 3,600 (1 hour). (Note: replaces `:extension`, which is deprecated.)
|
837
887
|
# * `:max_duration_per_lease_extension` [Integer] The maximum amount of time in seconds for a single lease
|
@@ -1016,14 +1066,19 @@ module Google
|
|
1016
1066
|
# * Any messages published to the subscription's topic following the
|
1017
1067
|
# successful completion of the `create_snapshot` operation.
|
1018
1068
|
#
|
1019
|
-
# @param [String, nil] snapshot_name Name of the new snapshot.
|
1020
|
-
# name is not provided, the server will assign a random name
|
1021
|
-
# for this snapshot on the same project as the subscription.
|
1022
|
-
#
|
1023
|
-
#
|
1024
|
-
#
|
1025
|
-
#
|
1026
|
-
#
|
1069
|
+
# @param [String, nil] snapshot_name Name of the new snapshot. Optional.
|
1070
|
+
# If the name is not provided, the server will assign a random name
|
1071
|
+
# for this snapshot on the same project as the subscription.
|
1072
|
+
# The value can be a simple snapshot ID (relative name), in which
|
1073
|
+
# case the current project ID will be supplied, or a fully-qualified
|
1074
|
+
# snapshot name in the form
|
1075
|
+
# `projects/{project_id}/snapshots/{snapshot_id}`.
|
1076
|
+
#
|
1077
|
+
# The snapshot ID (relative name) must start with a letter, and
|
1078
|
+
# contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
|
1079
|
+
# underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
|
1080
|
+
# signs (`%`). It must be between 3 and 255 characters in length, and
|
1081
|
+
# it must not start with `goog`.
|
1027
1082
|
# @param [Hash] labels A hash of user-provided labels associated with
|
1028
1083
|
# the snapshot. You can use these to organize and group your
|
1029
1084
|
# snapshots. Label keys and values can be no longer than 63
|
@@ -130,12 +130,12 @@ module Google
|
|
130
130
|
# puts subscription.name
|
131
131
|
# end
|
132
132
|
#
|
133
|
-
def all request_limit: nil
|
133
|
+
def all request_limit: nil, &block
|
134
134
|
request_limit = request_limit.to_i if request_limit
|
135
135
|
return enum_for :all, request_limit: request_limit unless block_given?
|
136
136
|
results = self
|
137
137
|
loop do
|
138
|
-
results.each
|
138
|
+
results.each(&block)
|
139
139
|
if request_limit
|
140
140
|
request_limit -= 1
|
141
141
|
break if request_limit.negative?
|
@@ -85,10 +85,10 @@ module Google
|
|
85
85
|
end
|
86
86
|
|
87
87
|
##
|
88
|
-
# The name of the topic
|
89
|
-
# "/projects/project-identifier/topics/topic-name".
|
88
|
+
# The name of the topic.
|
90
89
|
#
|
91
|
-
# @return [String]
|
90
|
+
# @return [String] A fully-qualified topic name in the form
|
91
|
+
# `projects/{project_id}/topics/{topic_id}`.
|
92
92
|
#
|
93
93
|
def name
|
94
94
|
return @resource_name if reference?
|
@@ -255,11 +255,17 @@ module Google
|
|
255
255
|
##
|
256
256
|
# Creates a new {Subscription} object on the current Topic.
|
257
257
|
#
|
258
|
-
# @param [String] subscription_name Name of the new subscription.
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
#
|
258
|
+
# @param [String] subscription_name Name of the new subscription. Required.
|
259
|
+
# The value can be a simple subscription ID (relative name), in which
|
260
|
+
# case the current project ID will be supplied, or a fully-qualified
|
261
|
+
# subscription name in the form
|
262
|
+
# `projects/{project_id}/subscriptions/{subscription_id}`.
|
263
|
+
#
|
264
|
+
# The subscription ID (relative name) must start with a letter, and
|
265
|
+
# contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
|
266
|
+
# underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
|
267
|
+
# signs (`%`). It must be between 3 and 255 characters in length, and
|
268
|
+
# it must not start with `goog`.
|
263
269
|
# @param [Integer] deadline The maximum number of seconds after a
|
264
270
|
# subscriber receives a message before the subscriber should
|
265
271
|
# acknowledge the message.
|
@@ -309,9 +315,6 @@ module Google
|
|
309
315
|
# will be retried as soon as possible for healthy subscribers. Retry Policy will be triggered on NACKs or
|
310
316
|
# acknowledgement deadline exceeded events for a given message.
|
311
317
|
#
|
312
|
-
# **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
|
313
|
-
# production use. It is not subject to any SLA or deprecation policy.
|
314
|
-
#
|
315
318
|
# @return [Google::Cloud::PubSub::Subscription]
|
316
319
|
#
|
317
320
|
# @example
|
@@ -418,7 +421,11 @@ module Google
|
|
418
421
|
##
|
419
422
|
# Retrieves subscription by name.
|
420
423
|
#
|
421
|
-
# @param [String] subscription_name Name of a subscription.
|
424
|
+
# @param [String] subscription_name Name of a subscription. The value
|
425
|
+
# can be a simple subscription ID (relative name), in which case the
|
426
|
+
# current project ID will be supplied, or a fully-qualified
|
427
|
+
# subscription name in the form
|
428
|
+
# `projects/{project_id}/subscriptions/{subscription_id}`.
|
422
429
|
# @param [Boolean] skip_lookup Optionally create a {Subscription} object
|
423
430
|
# without verifying the subscription resource exists on the Pub/Sub
|
424
431
|
# service. Calls made on this object will raise errors if the service
|
@@ -670,7 +677,7 @@ module Google
|
|
670
677
|
def publish_async data = nil, attributes = nil, ordering_key: nil, **extra_attrs, &callback
|
671
678
|
ensure_service!
|
672
679
|
|
673
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
680
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
674
681
|
@async_publisher.publish data, attributes, ordering_key: ordering_key, **extra_attrs, &callback
|
675
682
|
end
|
676
683
|
|
@@ -686,7 +693,7 @@ module Google
|
|
686
693
|
# {Subscription#listen}, and {Message#ordering_key}.
|
687
694
|
#
|
688
695
|
def enable_message_ordering!
|
689
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
696
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
690
697
|
@async_publisher.enable_message_ordering!
|
691
698
|
end
|
692
699
|
|
@@ -702,7 +709,7 @@ module Google
|
|
702
709
|
# @return [Boolean]
|
703
710
|
#
|
704
711
|
def message_ordering?
|
705
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
712
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
706
713
|
@async_publisher.message_ordering?
|
707
714
|
end
|
708
715
|
|
@@ -715,7 +722,7 @@ module Google
|
|
715
722
|
# @return [boolean] `true` when resumed, `false` otherwise.
|
716
723
|
#
|
717
724
|
def resume_publish ordering_key
|
718
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
725
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
719
726
|
@async_publisher.resume_publish ordering_key
|
720
727
|
end
|
721
728
|
|
@@ -124,12 +124,12 @@ module Google
|
|
124
124
|
# puts topic.name
|
125
125
|
# end
|
126
126
|
#
|
127
|
-
def all request_limit: nil
|
127
|
+
def all request_limit: nil, &block
|
128
128
|
request_limit = request_limit.to_i if request_limit
|
129
129
|
return enum_for :all, request_limit: request_limit unless block_given?
|
130
130
|
results = self
|
131
131
|
loop do
|
132
|
-
results.each
|
132
|
+
results.each(&block)
|
133
133
|
if request_limit
|
134
134
|
request_limit -= 1
|
135
135
|
break if request_limit.negative?
|
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: 2.
|
4
|
+
version: 2.4.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:
|
12
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.
|
76
|
+
version: 1.25.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 1.
|
83
|
+
version: 1.25.1
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: minitest
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -252,14 +252,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
252
|
requirements:
|
253
253
|
- - ">="
|
254
254
|
- !ruby/object:Gem::Version
|
255
|
-
version: '2.
|
255
|
+
version: '2.5'
|
256
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
257
|
requirements:
|
258
258
|
- - ">="
|
259
259
|
- !ruby/object:Gem::Version
|
260
260
|
version: '0'
|
261
261
|
requirements: []
|
262
|
-
rubygems_version: 3.
|
262
|
+
rubygems_version: 3.2.13
|
263
263
|
signing_key:
|
264
264
|
specification_version: 4
|
265
265
|
summary: API Client library for Google Cloud Pub/Sub
|