google-cloud-pubsub 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/google/cloud/pubsub.rb +0 -4
- data/lib/google/cloud/pubsub/async_publisher.rb +42 -6
- data/lib/google/cloud/pubsub/async_publisher/batch.rb +2 -6
- data/lib/google/cloud/pubsub/errors.rb +8 -0
- data/lib/google/cloud/pubsub/flow_controller.rb +139 -0
- data/lib/google/cloud/pubsub/project.rb +28 -8
- data/lib/google/cloud/pubsub/schema.rb +5 -5
- data/lib/google/cloud/pubsub/topic.rb +12 -0
- data/lib/google/cloud/pubsub/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6636ac65229c0dc438c63fa9aebda474396701364bfbea7e5da460ceea50a26
|
4
|
+
data.tar.gz: a0c0cafbbaf4083c1141d851dc6cecb8cb70bc01df940a139fe21d057aa2fb97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a187e9935196b66d4be65c7cf7b34148de36197f9e2c5e9144ccc9f78652370d7a441b33e14a002133b05aa6565cc38998912277e8896d81178bf5712ce9df8c
|
7
|
+
data.tar.gz: ee801f9d5959f5e2a38ccf13beaac930ca4629c81a268b627a8bacc7ad9ce430581fd690100fa5ef57b4fa5e20e3c5f40d72e905ce2535d978398f03112a48eb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 2.7.0 / 2021-06-15
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Add Publisher Flow Control
|
8
|
+
* Add flow_control to async options in Project#create_topic and Project#topic
|
9
|
+
* Add FlowControlLimitError
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* Fix Project#schema and #schemas to return full resource
|
14
|
+
* Include schema definition in default return values.
|
15
|
+
* Fix Schema#definition to return nil instead of empty string when not present.
|
16
|
+
|
3
17
|
### 2.6.1 / 2021-04-28
|
4
18
|
|
5
19
|
#### Bug Fixes
|
data/lib/google/cloud/pubsub.rb
CHANGED
@@ -33,8 +33,6 @@ module Google
|
|
33
33
|
# See {file:OVERVIEW.md Google Cloud Pub/Sub Overview}.
|
34
34
|
#
|
35
35
|
module PubSub
|
36
|
-
# rubocop:disable Metrics/AbcSize
|
37
|
-
|
38
36
|
##
|
39
37
|
# Creates a new object for connecting to the Pub/Sub service.
|
40
38
|
# Each call creates a new connection.
|
@@ -110,8 +108,6 @@ module Google
|
|
110
108
|
PubSub::Project.new service
|
111
109
|
end
|
112
110
|
|
113
|
-
# rubocop:enable Metrics/AbcSize
|
114
|
-
|
115
111
|
##
|
116
112
|
# Configure the Google Cloud PubSub library.
|
117
113
|
#
|
@@ -16,6 +16,7 @@
|
|
16
16
|
require "monitor"
|
17
17
|
require "concurrent"
|
18
18
|
require "google/cloud/pubsub/errors"
|
19
|
+
require "google/cloud/pubsub/flow_controller"
|
19
20
|
require "google/cloud/pubsub/async_publisher/batch"
|
20
21
|
require "google/cloud/pubsub/publish_result"
|
21
22
|
require "google/cloud/pubsub/service"
|
@@ -65,14 +66,21 @@ module Google
|
|
65
66
|
attr_reader :interval
|
66
67
|
attr_reader :publish_threads
|
67
68
|
attr_reader :callback_threads
|
69
|
+
attr_reader :flow_control
|
68
70
|
##
|
69
71
|
# @private Implementation accessors
|
70
72
|
attr_reader :service, :batch, :publish_thread_pool,
|
71
|
-
:callback_thread_pool
|
73
|
+
:callback_thread_pool, :flow_controller
|
72
74
|
|
73
75
|
##
|
74
76
|
# @private Create a new instance of the object.
|
75
|
-
def initialize topic_name,
|
77
|
+
def initialize topic_name,
|
78
|
+
service,
|
79
|
+
max_bytes: 1_000_000,
|
80
|
+
max_messages: 100,
|
81
|
+
interval: 0.01,
|
82
|
+
threads: {},
|
83
|
+
flow_control: {}
|
76
84
|
# init MonitorMixin
|
77
85
|
super()
|
78
86
|
@topic_name = service.topic_path topic_name
|
@@ -83,6 +91,10 @@ module Google
|
|
83
91
|
@interval = interval
|
84
92
|
@publish_threads = (threads[:publish] || 2).to_i
|
85
93
|
@callback_threads = (threads[:callback] || 4).to_i
|
94
|
+
@flow_control = {
|
95
|
+
message_limit: 10 * @max_messages,
|
96
|
+
byte_limit: 10 * @max_bytes
|
97
|
+
}.merge(flow_control).freeze
|
86
98
|
|
87
99
|
@published_at = nil
|
88
100
|
@publish_thread_pool = Concurrent::ThreadPoolExecutor.new max_threads: @publish_threads
|
@@ -91,7 +103,7 @@ module Google
|
|
91
103
|
@ordered = false
|
92
104
|
@batches = {}
|
93
105
|
@cond = new_cond
|
94
|
-
|
106
|
+
@flow_controller = FlowController.new(**@flow_control)
|
95
107
|
@thread = Thread.new { run_background }
|
96
108
|
end
|
97
109
|
|
@@ -121,13 +133,22 @@ module Google
|
|
121
133
|
#
|
122
134
|
def publish data = nil, attributes = nil, ordering_key: nil, **extra_attrs, &callback
|
123
135
|
msg = Convert.pubsub_message data, attributes, ordering_key, extra_attrs
|
136
|
+
begin
|
137
|
+
@flow_controller.acquire msg.to_proto.bytesize
|
138
|
+
rescue FlowControlLimitError => e
|
139
|
+
stop_publish ordering_key, e if ordering_key
|
140
|
+
raise
|
141
|
+
end
|
124
142
|
|
125
143
|
synchronize do
|
126
144
|
raise AsyncPublisherStopped if @stopped
|
127
145
|
raise OrderedMessagesDisabled if !@ordered && !msg.ordering_key.empty? # default is empty string
|
128
146
|
|
129
147
|
batch = resolve_batch_for_message msg
|
130
|
-
|
148
|
+
if batch.canceled?
|
149
|
+
@flow_controller.release msg.to_proto.bytesize
|
150
|
+
raise OrderingKeyError, batch.ordering_key
|
151
|
+
end
|
131
152
|
batch_action = batch.add msg, callback
|
132
153
|
if batch_action == :full
|
133
154
|
publish_batches!
|
@@ -305,6 +326,21 @@ module Google
|
|
305
326
|
@batches[ordering_key]
|
306
327
|
end
|
307
328
|
|
329
|
+
def stop_publish ordering_key, err
|
330
|
+
synchronize do
|
331
|
+
batch = resolve_batch_for_ordering_key ordering_key
|
332
|
+
return if batch.nil?
|
333
|
+
items = batch.cancel!
|
334
|
+
items.each do |item|
|
335
|
+
@flow_controller.release item.bytesize
|
336
|
+
next unless item.callback
|
337
|
+
|
338
|
+
publish_result = PublishResult.from_error item.msg, err
|
339
|
+
execute_callback_async item.callback, publish_result
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
308
344
|
def publish_batches! stop: nil
|
309
345
|
@batches.reject! { |_ordering_key, batch| batch.empty? }
|
310
346
|
@batches.each_value do |batch|
|
@@ -325,7 +361,6 @@ module Google
|
|
325
361
|
end
|
326
362
|
|
327
363
|
# rubocop:disable Metrics/AbcSize
|
328
|
-
# rubocop:disable Metrics/MethodLength
|
329
364
|
|
330
365
|
def publish_batch_sync topic_name, batch
|
331
366
|
# The only batch methods that are safe to call from the loop are
|
@@ -337,6 +372,7 @@ module Google
|
|
337
372
|
unless items.empty?
|
338
373
|
grpc = @service.publish topic_name, items.map(&:msg)
|
339
374
|
items.zip Array(grpc.message_ids) do |item, id|
|
375
|
+
@flow_controller.release item.bytesize
|
340
376
|
next unless item.callback
|
341
377
|
|
342
378
|
item.msg.message_id = id
|
@@ -363,6 +399,7 @@ module Google
|
|
363
399
|
end
|
364
400
|
|
365
401
|
items.each do |item|
|
402
|
+
@flow_controller.release item.bytesize
|
366
403
|
next unless item.callback
|
367
404
|
|
368
405
|
publish_result = PublishResult.from_error item.msg, e
|
@@ -374,7 +411,6 @@ module Google
|
|
374
411
|
end
|
375
412
|
|
376
413
|
# rubocop:enable Metrics/AbcSize
|
377
|
-
# rubocop:enable Metrics/MethodLength
|
378
414
|
|
379
415
|
PUBLISH_RETRY_ERRORS = [
|
380
416
|
GRPC::Cancelled, GRPC::DeadlineExceeded, GRPC::Internal,
|
@@ -129,8 +129,8 @@ module Google
|
|
129
129
|
end
|
130
130
|
|
131
131
|
##
|
132
|
-
#
|
133
|
-
# the active item list.
|
132
|
+
# Fills the batch by sequentially moving the queued items that will
|
133
|
+
# fit into the active item list.
|
134
134
|
#
|
135
135
|
# This method is only intended to be used by the active publishing
|
136
136
|
# job.
|
@@ -152,8 +152,6 @@ module Google
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
# rubocop:disable Metrics/MethodLength
|
156
|
-
|
157
155
|
##
|
158
156
|
# Resets the batch after a successful publish. This clears the active
|
159
157
|
# item list and moves the queued items that will fit into the active
|
@@ -202,8 +200,6 @@ module Google
|
|
202
200
|
true
|
203
201
|
end
|
204
202
|
|
205
|
-
# rubocop:enable Metrics/MethodLength
|
206
|
-
|
207
203
|
##
|
208
204
|
# Cancel the batch and hault futher batches until resumed. See
|
209
205
|
# {#resume!} and {#canceled?}.
|
@@ -78,6 +78,14 @@ module Google
|
|
78
78
|
super "Can't publish message using #{ordering_key}."
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Raised when the desired action is `error` and the message would exceed
|
84
|
+
# flow control limits, or when the desired action is `block` and the
|
85
|
+
# message would block forever against the flow control limits.
|
86
|
+
#
|
87
|
+
class FlowControlLimitError < Google::Cloud::Error
|
88
|
+
end
|
81
89
|
end
|
82
90
|
|
83
91
|
Pubsub = PubSub unless const_defined? :Pubsub
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# Copyright 2021 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/errors"
|
17
|
+
require "concurrent/atomics"
|
18
|
+
|
19
|
+
module Google
|
20
|
+
module Cloud
|
21
|
+
module PubSub
|
22
|
+
##
|
23
|
+
# @private
|
24
|
+
#
|
25
|
+
# Used to control the flow of messages passing through it.
|
26
|
+
#
|
27
|
+
class FlowController
|
28
|
+
attr_reader :message_limit
|
29
|
+
attr_reader :byte_limit
|
30
|
+
attr_reader :limit_exceeded_behavior
|
31
|
+
##
|
32
|
+
# @private Implementation accessors
|
33
|
+
attr_reader :outstanding_messages, :outstanding_bytes, :awaiting
|
34
|
+
|
35
|
+
def initialize message_limit: 1000, byte_limit: 10_000_000, limit_exceeded_behavior: :ignore
|
36
|
+
unless [:ignore, :error, :block].include? limit_exceeded_behavior
|
37
|
+
raise ArgumentError, "limit_exceeded_behavior must be one of :ignore, :error, :block"
|
38
|
+
end
|
39
|
+
if [:error, :block].include?(limit_exceeded_behavior) && message_limit < 1
|
40
|
+
raise ArgumentError,
|
41
|
+
"Flow control message limit (#{message_limit}) exceeded by a single message, would block forever"
|
42
|
+
end
|
43
|
+
@mutex = Mutex.new
|
44
|
+
@message_limit = message_limit
|
45
|
+
@byte_limit = byte_limit
|
46
|
+
@limit_exceeded_behavior = limit_exceeded_behavior
|
47
|
+
@outstanding_messages = 0
|
48
|
+
@outstanding_bytes = 0
|
49
|
+
|
50
|
+
@awaiting = []
|
51
|
+
end
|
52
|
+
|
53
|
+
def acquire message_size
|
54
|
+
return if limit_exceeded_behavior == :ignore
|
55
|
+
@mutex.lock
|
56
|
+
if limit_exceeded_behavior == :error && would_exceed_message_limit?
|
57
|
+
raise FlowControlLimitError, "Flow control message limit (#{message_limit}) would be exceeded"
|
58
|
+
end
|
59
|
+
if limit_exceeded_behavior == :error && would_exceed_byte_limit?(message_size)
|
60
|
+
raise FlowControlLimitError,
|
61
|
+
"Flow control byte limit (#{byte_limit}) would be exceeded, message_size: #{message_size}"
|
62
|
+
end
|
63
|
+
if limit_exceeded_behavior == :block && message_size > byte_limit
|
64
|
+
raise FlowControlLimitError,
|
65
|
+
"Flow control byte limit (#{byte_limit}) exceeded by a single message, would block forever"
|
66
|
+
end
|
67
|
+
|
68
|
+
acquire_or_wait message_size
|
69
|
+
ensure
|
70
|
+
@mutex.unlock if @mutex.owned?
|
71
|
+
end
|
72
|
+
|
73
|
+
def release message_size
|
74
|
+
return if limit_exceeded_behavior == :ignore
|
75
|
+
@mutex.synchronize do
|
76
|
+
raise "Flow control messages count would be negative" if (@outstanding_messages - 1).negative?
|
77
|
+
raise "Flow control bytes count would be negative" if (@outstanding_bytes - message_size).negative?
|
78
|
+
|
79
|
+
@outstanding_messages -= 1
|
80
|
+
@outstanding_bytes -= message_size
|
81
|
+
@awaiting.first.set unless @awaiting.empty?
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
|
87
|
+
# rubocop:disable Style/IdenticalConditionalBranches
|
88
|
+
# rubocop:disable Style/GuardClause
|
89
|
+
|
90
|
+
def acquire_or_wait message_size
|
91
|
+
waiter = nil
|
92
|
+
while is_new_and_others_wait?(waiter) ||
|
93
|
+
would_exceed_byte_limit?(message_size) ||
|
94
|
+
would_exceed_message_limit?
|
95
|
+
|
96
|
+
if waiter.nil?
|
97
|
+
waiter = Concurrent::Event.new
|
98
|
+
# This waiter gets added to the back of the line.
|
99
|
+
@awaiting << waiter
|
100
|
+
else
|
101
|
+
waiter = Concurrent::Event.new
|
102
|
+
# This waiter already in line stays at the head of the line.
|
103
|
+
@awaiting[0] = waiter
|
104
|
+
end
|
105
|
+
@mutex.unlock
|
106
|
+
waiter.wait
|
107
|
+
@mutex.lock
|
108
|
+
end
|
109
|
+
@outstanding_messages += 1
|
110
|
+
@outstanding_bytes += message_size
|
111
|
+
|
112
|
+
@awaiting.shift if waiter # Remove the newly released waiter from the head of the queue.
|
113
|
+
|
114
|
+
# There may be some surplus left; let the next message waiting try to acquire a permit.
|
115
|
+
if !@awaiting.empty? && @outstanding_bytes < byte_limit && @outstanding_messages < message_limit
|
116
|
+
@awaiting.first.set
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# rubocop:enable Style/IdenticalConditionalBranches
|
121
|
+
# rubocop:enable Style/GuardClause
|
122
|
+
|
123
|
+
def is_new_and_others_wait? waiter
|
124
|
+
waiter.nil? && !@awaiting.empty?
|
125
|
+
end
|
126
|
+
|
127
|
+
def would_exceed_message_limit?
|
128
|
+
@outstanding_messages + 1 > message_limit
|
129
|
+
end
|
130
|
+
|
131
|
+
def would_exceed_byte_limit? bytes_requested
|
132
|
+
@outstanding_bytes + bytes_requested > byte_limit
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
Pubsub = PubSub unless const_defined? :Pubsub
|
138
|
+
end
|
139
|
+
end
|
@@ -103,6 +103,16 @@ module Google
|
|
103
103
|
# * `:threads` (Hash) The number of threads to create to handle concurrent calls by the publisher:
|
104
104
|
# * `:publish` (Integer) The number of threads used to publish messages. Default is 2.
|
105
105
|
# * `:callback` (Integer) The number of threads to handle the published messages' callbacks. Default is 4.
|
106
|
+
# * `:flow_control` (Hash) The client flow control settings for message publishing:
|
107
|
+
# * `:message_limit` (Integer) The maximum number of messages allowed to wait to be published. Default is
|
108
|
+
# `10 * max_messages`.
|
109
|
+
# * `:byte_limit` (Integer) The maximum total size of messages allowed to wait to be published. Default is
|
110
|
+
# `10 * max_bytes`.
|
111
|
+
# * `:limit_exceeded_behavior` (Symbol) The action to take when publish flow control limits are exceeded.
|
112
|
+
# Possible values include: `:ignore` - Flow control is disabled. `:error` - Calls to {Topic#publish_async}
|
113
|
+
# will raise {FlowControlLimitError} when publish flow control limits are exceeded. `:block` - Calls to
|
114
|
+
# {Topic#publish_async} will block until capacity is available when publish flow control limits are
|
115
|
+
# exceeded. The default value is `:ignore`.
|
106
116
|
#
|
107
117
|
# @return [Google::Cloud::PubSub::Topic, nil] Returns `nil` if topic
|
108
118
|
# does not exist.
|
@@ -206,6 +216,16 @@ module Google
|
|
206
216
|
# Default is 2.
|
207
217
|
# * `:callback` (Integer) The number of threads to handle the published
|
208
218
|
# messages' callbacks. Default is 4.
|
219
|
+
# * `:flow_control` (Hash) The client flow control settings for message publishing:
|
220
|
+
# * `:message_limit` (Integer) The maximum number of messages allowed to wait to be published. Default is
|
221
|
+
# `10 * max_messages`.
|
222
|
+
# * `:byte_limit` (Integer) The maximum total size of messages allowed to wait to be published. Default is
|
223
|
+
# `10 * max_bytes`.
|
224
|
+
# * `:limit_exceeded_behavior` (Symbol) The action to take when publish flow control limits are exceeded.
|
225
|
+
# Possible values include: `:ignore` - Flow control is disabled. `:error` - Calls to {Topic#publish_async}
|
226
|
+
# will raise {FlowControlLimitError} when publish flow control limits are exceeded. `:block` - Calls to
|
227
|
+
# {Topic#publish_async} will block until capacity is available when publish flow control limits are
|
228
|
+
# exceeded. The default value is `:ignore`.
|
209
229
|
# @param [String] schema_name The name of the schema that messages
|
210
230
|
# published should be validated against. Optional. The value can be a
|
211
231
|
# simple schema ID (relative name), in which case the current project
|
@@ -423,7 +443,7 @@ module Google
|
|
423
443
|
# * `BASIC` - Include the `name` and `type` of the schema, but not the `definition`.
|
424
444
|
# * `FULL` - Include all Schema object fields.
|
425
445
|
#
|
426
|
-
# The default value is `
|
446
|
+
# The default value is `FULL`.
|
427
447
|
# @param [String] project If the schema belongs to a project other
|
428
448
|
# than the one currently connected to, the alternate project ID can be
|
429
449
|
# specified here. Not used if a fully-qualified schema name is
|
@@ -444,7 +464,7 @@ module Google
|
|
444
464
|
# schema = pubsub.schema "my-schema"
|
445
465
|
# schema.name #=> "projects/my-project/schemas/my-schema"
|
446
466
|
# schema.type #=> :PROTOCOL_BUFFER
|
447
|
-
#
|
467
|
+
# schema.definition # The schema definition
|
448
468
|
#
|
449
469
|
# @example Skip the lookup against the service with `skip_lookup`:
|
450
470
|
# require "google/cloud/pubsub"
|
@@ -458,21 +478,21 @@ module Google
|
|
458
478
|
# schema.type #=> nil
|
459
479
|
# schema.definition #=> nil
|
460
480
|
#
|
461
|
-
# @example
|
481
|
+
# @example Omit the schema definition with `view: :basic`:
|
462
482
|
# require "google/cloud/pubsub"
|
463
483
|
#
|
464
484
|
# pubsub = Google::Cloud::PubSub.new
|
465
485
|
#
|
466
|
-
# schema = pubsub.schema "my-schema", view: :
|
486
|
+
# schema = pubsub.schema "my-schema", view: :basic
|
467
487
|
# schema.name #=> "projects/my-project/schemas/my-schema"
|
468
488
|
# schema.type #=> :PROTOCOL_BUFFER
|
469
|
-
# schema.definition
|
489
|
+
# schema.definition #=> nil
|
470
490
|
#
|
471
491
|
def schema schema_name, view: nil, project: nil, skip_lookup: nil
|
472
492
|
ensure_service!
|
473
493
|
options = { project: project }
|
474
494
|
return Schema.from_name schema_name, view, service, options if skip_lookup
|
475
|
-
view ||= :
|
495
|
+
view ||= :FULL
|
476
496
|
grpc = service.get_schema schema_name, view, options
|
477
497
|
Schema.from_grpc grpc, service
|
478
498
|
rescue Google::Cloud::NotFoundError
|
@@ -531,7 +551,7 @@ module Google
|
|
531
551
|
# * `BASIC` - Include the `name` and `type` of the schema, but not the `definition`.
|
532
552
|
# * `FULL` - Include all Schema object fields.
|
533
553
|
#
|
534
|
-
# The default value is `
|
554
|
+
# The default value is `FULL`.
|
535
555
|
# @param [String] token A previously-returned page token representing
|
536
556
|
# part of the larger set of results to view.
|
537
557
|
# @param [Integer] max Maximum number of schemas to return.
|
@@ -561,7 +581,7 @@ module Google
|
|
561
581
|
#
|
562
582
|
def schemas view: nil, token: nil, max: nil
|
563
583
|
ensure_service!
|
564
|
-
view ||= :
|
584
|
+
view ||= :FULL
|
565
585
|
options = { token: token, max: max }
|
566
586
|
grpc = service.list_schemas view, options
|
567
587
|
Schema::List.from_grpc grpc, service, view, max
|
@@ -48,7 +48,7 @@ module Google
|
|
48
48
|
@grpc = grpc
|
49
49
|
@service = service
|
50
50
|
@exists = nil
|
51
|
-
@view = view || :
|
51
|
+
@view = view || :FULL
|
52
52
|
end
|
53
53
|
|
54
54
|
##
|
@@ -81,7 +81,7 @@ module Google
|
|
81
81
|
#
|
82
82
|
def definition
|
83
83
|
return nil if reference?
|
84
|
-
@grpc.definition
|
84
|
+
@grpc.definition if @grpc.definition && !@grpc.definition.empty?
|
85
85
|
end
|
86
86
|
|
87
87
|
##
|
@@ -141,7 +141,7 @@ module Google
|
|
141
141
|
# * `FULL` - Include all Schema object fields.
|
142
142
|
#
|
143
143
|
# Optional. If not provided or `nil`, the last non-nil `view` argument to this method will be used if one has
|
144
|
-
# been given, othewise `
|
144
|
+
# been given, othewise `FULL` will be used.
|
145
145
|
#
|
146
146
|
# @return [Google::Cloud::PubSub::Schema] Returns the reloaded schema.
|
147
147
|
#
|
@@ -153,7 +153,7 @@ module Google
|
|
153
153
|
#
|
154
154
|
# schema.reload!
|
155
155
|
#
|
156
|
-
# @example Use the `view` option to load the full resource:
|
156
|
+
# @example Use the `view` option to load the basic or full resource:
|
157
157
|
# require "google/cloud/pubsub"
|
158
158
|
#
|
159
159
|
# pubsub = Google::Cloud::PubSub.new
|
@@ -267,7 +267,7 @@ module Google
|
|
267
267
|
# require "google/cloud/pubsub"
|
268
268
|
#
|
269
269
|
# pubsub = Google::Cloud::PubSub.new
|
270
|
-
# schema = pubsub.schema "my-schema"
|
270
|
+
# schema = pubsub.schema "my-schema"
|
271
271
|
#
|
272
272
|
# schema.resource_full? #=> true
|
273
273
|
#
|
@@ -684,6 +684,11 @@ module Google
|
|
684
684
|
# @note At the time of this release, ordering keys are not yet publicly
|
685
685
|
# enabled and requires special project enablements.
|
686
686
|
#
|
687
|
+
# Publisher flow control limits the number of outstanding messages that
|
688
|
+
# are allowed to wait to be published. See the `flow_control` key in the
|
689
|
+
# `async` parameter in {Project#topic} for more information about publisher
|
690
|
+
# flow control settings.
|
691
|
+
#
|
687
692
|
# @param [String, File] data The message payload. This will be converted
|
688
693
|
# to bytes encoded as ASCII-8BIT.
|
689
694
|
# @param [Hash] attributes Optional attributes for the message.
|
@@ -703,6 +708,13 @@ module Google
|
|
703
708
|
# message with an `ordering_key` that has already failed when
|
704
709
|
# publishing. Use {#resume_publish} to allow this `ordering_key` to be
|
705
710
|
# published again.
|
711
|
+
# @raise [Google::Cloud::PubSub::FlowControlLimitError] when publish flow
|
712
|
+
# control limits are exceeded, and the `async` parameter key
|
713
|
+
# `flow_control.limit_exceeded_behavior` is set to `:error` or `:block`.
|
714
|
+
# If `flow_control.limit_exceeded_behavior` is set to `:block`, this error
|
715
|
+
# will be raised only when a limit would be exceeded by a single message.
|
716
|
+
# See the `async` parameter in {Project#topic} for more information about
|
717
|
+
# `flow_control` settings.
|
706
718
|
#
|
707
719
|
# @example
|
708
720
|
# require "google/cloud/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: 2.
|
4
|
+
version: 2.7.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: 2021-
|
12
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- lib/google/cloud/pubsub/convert.rb
|
234
234
|
- lib/google/cloud/pubsub/credentials.rb
|
235
235
|
- lib/google/cloud/pubsub/errors.rb
|
236
|
+
- lib/google/cloud/pubsub/flow_controller.rb
|
236
237
|
- lib/google/cloud/pubsub/message.rb
|
237
238
|
- lib/google/cloud/pubsub/policy.rb
|
238
239
|
- lib/google/cloud/pubsub/project.rb
|
@@ -275,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
276
|
- !ruby/object:Gem::Version
|
276
277
|
version: '0'
|
277
278
|
requirements: []
|
278
|
-
rubygems_version: 3.2.
|
279
|
+
rubygems_version: 3.2.17
|
279
280
|
signing_key:
|
280
281
|
specification_version: 4
|
281
282
|
summary: API Client library for Google Cloud Pub/Sub
|