google-cloud-pubsub 2.15.1 → 2.15.2
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 +6 -0
- data/lib/google/cloud/pubsub/async_publisher/batch.rb +27 -14
- data/lib/google/cloud/pubsub/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b35d78bd1388f589340f93c8e9b9634e06a82406bfeb7cc134f3f9efe9126316
|
4
|
+
data.tar.gz: 74c1c0be39fcabaed038750157e891da276e13bb5017c57cbb62ccf542139421
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 066db5f0cd5bdbd207cf8b928bab86dbb9438d7418ad0a596f07547738311ddb8ead880110e1464aeac7b6a90b44d9b54c36b86d3d873c623c866885c948e62f
|
7
|
+
data.tar.gz: 51165f72d1a5813cae65c414915e907b9c15c8e6390ad9ba452b77a42cc6271d6d3b36fc62a97477bed12704d09d76993f0757c6cce8711c0f485eda0e5063f5
|
data/CHANGELOG.md
CHANGED
@@ -141,7 +141,7 @@ module Google
|
|
141
141
|
|
142
142
|
until @queue.empty?
|
143
143
|
item = @queue.first
|
144
|
-
if try_add item.msg, item.callback
|
144
|
+
if try_add item.msg, item.callback, item.create_time
|
145
145
|
@queue.shift
|
146
146
|
next
|
147
147
|
end
|
@@ -178,12 +178,7 @@ module Google
|
|
178
178
|
return false
|
179
179
|
end
|
180
180
|
|
181
|
-
|
182
|
-
item = @queue.first
|
183
|
-
added = try_add item.msg, item.callback
|
184
|
-
break unless added
|
185
|
-
@queue.shift
|
186
|
-
end
|
181
|
+
refill_items
|
187
182
|
|
188
183
|
return false unless @publishing
|
189
184
|
if @items.empty?
|
@@ -191,6 +186,7 @@ module Google
|
|
191
186
|
return false
|
192
187
|
else
|
193
188
|
return true if stopping?
|
189
|
+
return true if interval_met?(@items.first.create_time) || batch_full_by_count?
|
194
190
|
if @queue.empty?
|
195
191
|
@publishing = false
|
196
192
|
return false
|
@@ -261,16 +257,33 @@ module Google
|
|
261
257
|
|
262
258
|
protected
|
263
259
|
|
264
|
-
def
|
265
|
-
|
260
|
+
def interval_met? create_time
|
261
|
+
Time.now - create_time > @publisher.interval
|
262
|
+
end
|
263
|
+
|
264
|
+
def batch_full_by_count?
|
265
|
+
total_message_count == @publisher.max_messages
|
266
|
+
end
|
267
|
+
|
268
|
+
def refill_items
|
269
|
+
until @queue.empty?
|
270
|
+
item = @queue.first
|
271
|
+
added = try_add item.msg, item.callback, item.create_time
|
272
|
+
break unless added
|
273
|
+
@queue.shift
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def items_add msg, callback, create_time
|
278
|
+
item = Item.new msg, callback, (create_time || Time.now)
|
266
279
|
@items << item
|
267
280
|
@total_message_bytes += item.bytesize + 2
|
268
281
|
end
|
269
282
|
|
270
|
-
def try_add msg, callback
|
283
|
+
def try_add msg, callback, create_time = nil
|
271
284
|
if @items.empty?
|
272
285
|
# Always add when empty, even if bytesize is bigger than total
|
273
|
-
items_add msg, callback
|
286
|
+
items_add msg, callback, create_time
|
274
287
|
return true
|
275
288
|
end
|
276
289
|
new_message_count = total_message_count + 1
|
@@ -279,12 +292,12 @@ module Google
|
|
279
292
|
new_message_bytes >= @publisher.max_bytes
|
280
293
|
return false
|
281
294
|
end
|
282
|
-
items_add msg, callback
|
295
|
+
items_add msg, callback, create_time
|
283
296
|
true
|
284
297
|
end
|
285
298
|
|
286
299
|
def queue_add msg, callback
|
287
|
-
item = Item.new msg, callback
|
300
|
+
item = Item.new msg, callback, Time.now
|
288
301
|
@queue << item
|
289
302
|
end
|
290
303
|
|
@@ -292,7 +305,7 @@ module Google
|
|
292
305
|
@items.count
|
293
306
|
end
|
294
307
|
|
295
|
-
Item = Struct.new :msg, :callback do
|
308
|
+
Item = Struct.new :msg, :callback, :create_time do
|
296
309
|
def bytesize
|
297
310
|
msg.to_proto.bytesize
|
298
311
|
end
|
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.15.
|
4
|
+
version: 2.15.2
|
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: 2023-
|
12
|
+
date: 2023-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|