google-cloud-pubsub 2.2.0 → 2.5.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 +49 -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 +252 -18
- data/lib/google/cloud/pubsub/retry_policy.rb +2 -4
- data/lib/google/cloud/pubsub/schema.rb +310 -0
- data/lib/google/cloud/pubsub/schema/list.rb +180 -0
- data/lib/google/cloud/pubsub/service.rb +147 -32
- data/lib/google/cloud/pubsub/snapshot.rb +5 -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 +35 -18
- data/lib/google/cloud/pubsub/subscription/list.rb +2 -2
- data/lib/google/cloud/pubsub/topic.rb +95 -16
- data/lib/google/cloud/pubsub/topic/list.rb +2 -2
- data/lib/google/cloud/pubsub/version.rb +1 -1
- metadata +22 -6
@@ -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?
|
@@ -233,6 +233,78 @@ module Google
|
|
233
233
|
@resource_name = nil
|
234
234
|
end
|
235
235
|
|
236
|
+
##
|
237
|
+
# The name of the schema that messages published should be validated against, if schema settings are configured
|
238
|
+
# for the topic. The value is a fully-qualified schema name in the form
|
239
|
+
# `projects/{project_id}/schemas/{schema_id}`. If present, {#message_encoding} should also be present. The value
|
240
|
+
# of this field will be `_deleted-schema_` if the schema has been deleted.
|
241
|
+
#
|
242
|
+
# Makes an API call to retrieve the schema settings when called on a reference object. See {#reference?}.
|
243
|
+
#
|
244
|
+
# @return [String, nil] The schema name, or `nil` if schema settings are not configured for the topic.
|
245
|
+
#
|
246
|
+
# @example
|
247
|
+
# require "google/cloud/pubsub"
|
248
|
+
#
|
249
|
+
# pubsub = Google::Cloud::PubSub.new
|
250
|
+
#
|
251
|
+
# topic = pubsub.topic "my-topic"
|
252
|
+
#
|
253
|
+
# topic.schema_name #=> "projects/my-project/schemas/my-schema"
|
254
|
+
#
|
255
|
+
def schema_name
|
256
|
+
ensure_grpc!
|
257
|
+
@grpc.schema_settings&.schema
|
258
|
+
end
|
259
|
+
|
260
|
+
##
|
261
|
+
# The encoding of messages validated against the schema identified by {#schema_name}. If present, {#schema_name}
|
262
|
+
# should also be present. Values include:
|
263
|
+
#
|
264
|
+
# * `JSON` - JSON encoding.
|
265
|
+
# * `BINARY` - Binary encoding, as defined by the schema type. For some schema types, binary encoding may not be
|
266
|
+
# available.
|
267
|
+
#
|
268
|
+
# Makes an API call to retrieve the schema settings when called on a reference object. See {#reference?}.
|
269
|
+
#
|
270
|
+
# @return [Symbol, nil] The schema encoding, or `nil` if schema settings are not configured for the topic.
|
271
|
+
#
|
272
|
+
# @example
|
273
|
+
# require "google/cloud/pubsub"
|
274
|
+
#
|
275
|
+
# pubsub = Google::Cloud::PubSub.new
|
276
|
+
#
|
277
|
+
# topic = pubsub.topic "my-topic"
|
278
|
+
#
|
279
|
+
# topic.message_encoding #=> :JSON
|
280
|
+
#
|
281
|
+
def message_encoding
|
282
|
+
ensure_grpc!
|
283
|
+
@grpc.schema_settings&.encoding
|
284
|
+
end
|
285
|
+
|
286
|
+
##
|
287
|
+
# Checks if the encoding of messages in the schema settings is `BINARY`. See {#message_encoding}.
|
288
|
+
#
|
289
|
+
# Makes an API call to retrieve the schema settings when called on a reference object. See {#reference?}.
|
290
|
+
#
|
291
|
+
# @return [Boolean] `true` when `BINARY`, `false` if not `BINARY` or schema settings is not set.
|
292
|
+
#
|
293
|
+
def message_encoding_binary?
|
294
|
+
message_encoding.to_s.upcase == "BINARY"
|
295
|
+
end
|
296
|
+
|
297
|
+
##
|
298
|
+
# Checks if the encoding of messages in the schema settings is `JSON`. See {#message_encoding}.
|
299
|
+
#
|
300
|
+
# Makes an API call to retrieve the schema settings when called on a reference object. See {#reference?}.
|
301
|
+
#
|
302
|
+
# @return [Boolean] `true` when `JSON`, `false` if not `JSON` or schema settings is not set.
|
303
|
+
#
|
304
|
+
def message_encoding_json?
|
305
|
+
message_encoding.to_s.upcase == "JSON"
|
306
|
+
end
|
307
|
+
|
236
308
|
##
|
237
309
|
# Permanently deletes the topic.
|
238
310
|
#
|
@@ -255,11 +327,17 @@ module Google
|
|
255
327
|
##
|
256
328
|
# Creates a new {Subscription} object on the current Topic.
|
257
329
|
#
|
258
|
-
# @param [String] subscription_name Name of the new subscription.
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
#
|
330
|
+
# @param [String] subscription_name Name of the new subscription. Required.
|
331
|
+
# The value can be a simple subscription ID (relative name), in which
|
332
|
+
# case the current project ID will be supplied, or a fully-qualified
|
333
|
+
# subscription name in the form
|
334
|
+
# `projects/{project_id}/subscriptions/{subscription_id}`.
|
335
|
+
#
|
336
|
+
# The subscription ID (relative name) must start with a letter, and
|
337
|
+
# contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
|
338
|
+
# underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
|
339
|
+
# signs (`%`). It must be between 3 and 255 characters in length, and
|
340
|
+
# it must not start with `goog`.
|
263
341
|
# @param [Integer] deadline The maximum number of seconds after a
|
264
342
|
# subscriber receives a message before the subscriber should
|
265
343
|
# acknowledge the message.
|
@@ -309,9 +387,6 @@ module Google
|
|
309
387
|
# will be retried as soon as possible for healthy subscribers. Retry Policy will be triggered on NACKs or
|
310
388
|
# acknowledgement deadline exceeded events for a given message.
|
311
389
|
#
|
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
390
|
# @return [Google::Cloud::PubSub::Subscription]
|
316
391
|
#
|
317
392
|
# @example
|
@@ -418,7 +493,11 @@ module Google
|
|
418
493
|
##
|
419
494
|
# Retrieves subscription by name.
|
420
495
|
#
|
421
|
-
# @param [String] subscription_name Name of a subscription.
|
496
|
+
# @param [String] subscription_name Name of a subscription. The value
|
497
|
+
# can be a simple subscription ID (relative name), in which case the
|
498
|
+
# current project ID will be supplied, or a fully-qualified
|
499
|
+
# subscription name in the form
|
500
|
+
# `projects/{project_id}/subscriptions/{subscription_id}`.
|
422
501
|
# @param [Boolean] skip_lookup Optionally create a {Subscription} object
|
423
502
|
# without verifying the subscription resource exists on the Pub/Sub
|
424
503
|
# service. Calls made on this object will raise errors if the service
|
@@ -670,7 +749,7 @@ module Google
|
|
670
749
|
def publish_async data = nil, attributes = nil, ordering_key: nil, **extra_attrs, &callback
|
671
750
|
ensure_service!
|
672
751
|
|
673
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
752
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
674
753
|
@async_publisher.publish data, attributes, ordering_key: ordering_key, **extra_attrs, &callback
|
675
754
|
end
|
676
755
|
|
@@ -686,7 +765,7 @@ module Google
|
|
686
765
|
# {Subscription#listen}, and {Message#ordering_key}.
|
687
766
|
#
|
688
767
|
def enable_message_ordering!
|
689
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
768
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
690
769
|
@async_publisher.enable_message_ordering!
|
691
770
|
end
|
692
771
|
|
@@ -702,7 +781,7 @@ module Google
|
|
702
781
|
# @return [Boolean]
|
703
782
|
#
|
704
783
|
def message_ordering?
|
705
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
784
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
706
785
|
@async_publisher.message_ordering?
|
707
786
|
end
|
708
787
|
|
@@ -715,7 +794,7 @@ module Google
|
|
715
794
|
# @return [boolean] `true` when resumed, `false` otherwise.
|
716
795
|
#
|
717
796
|
def resume_publish ordering_key
|
718
|
-
@async_publisher ||= AsyncPublisher.new name, service,
|
797
|
+
@async_publisher ||= AsyncPublisher.new name, service, **@async_opts
|
719
798
|
@async_publisher.resume_publish ordering_key
|
720
799
|
end
|
721
800
|
|
@@ -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.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:
|
12
|
+
date: 2021-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -67,20 +67,34 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: avro
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.10'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.10'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: google-style
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
88
|
- - "~>"
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.
|
90
|
+
version: 1.25.1
|
77
91
|
type: :development
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
95
|
- - "~>"
|
82
96
|
- !ruby/object:Gem::Version
|
83
|
-
version: 1.
|
97
|
+
version: 1.25.1
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: minitest
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,6 +239,8 @@ files:
|
|
225
239
|
- lib/google/cloud/pubsub/publish_result.rb
|
226
240
|
- lib/google/cloud/pubsub/received_message.rb
|
227
241
|
- lib/google/cloud/pubsub/retry_policy.rb
|
242
|
+
- lib/google/cloud/pubsub/schema.rb
|
243
|
+
- lib/google/cloud/pubsub/schema/list.rb
|
228
244
|
- lib/google/cloud/pubsub/service.rb
|
229
245
|
- lib/google/cloud/pubsub/snapshot.rb
|
230
246
|
- lib/google/cloud/pubsub/snapshot/list.rb
|
@@ -252,14 +268,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
268
|
requirements:
|
253
269
|
- - ">="
|
254
270
|
- !ruby/object:Gem::Version
|
255
|
-
version: '2.
|
271
|
+
version: '2.5'
|
256
272
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
257
273
|
requirements:
|
258
274
|
- - ">="
|
259
275
|
- !ruby/object:Gem::Version
|
260
276
|
version: '0'
|
261
277
|
requirements: []
|
262
|
-
rubygems_version: 3.
|
278
|
+
rubygems_version: 3.2.13
|
263
279
|
signing_key:
|
264
280
|
specification_version: 4
|
265
281
|
summary: API Client library for Google Cloud Pub/Sub
|