google-cloud-pubsub 2.15.0 → 2.15.2

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: 487a660ea90e29fd8dcde076a9baf33aabefdba1d06267160b56254129b2af1a
4
- data.tar.gz: 21138b050ced799b7a16cd2048a321d6be6f488457474c313a9976236d4599ab
3
+ metadata.gz: b35d78bd1388f589340f93c8e9b9634e06a82406bfeb7cc134f3f9efe9126316
4
+ data.tar.gz: 74c1c0be39fcabaed038750157e891da276e13bb5017c57cbb62ccf542139421
5
5
  SHA512:
6
- metadata.gz: 6a4aded9ee5ca61d0496ec669d6fdf1ac842eab912409cf2c2b2b52059d0151cfd7ff847c0d64b0be32946fb5484d8bfaf9499f8e061cee386868969179e11fd
7
- data.tar.gz: 2964d7408a959048069ee489f22b72427ba6713453518b0a79cb660fef25ca38951f9d5ad5d903494757ed325932238309ff271e6f460718f6b337e294738eb5
6
+ metadata.gz: 066db5f0cd5bdbd207cf8b928bab86dbb9438d7418ad0a596f07547738311ddb8ead880110e1464aeac7b6a90b44d9b54c36b86d3d873c623c866885c948e62f
7
+ data.tar.gz: 51165f72d1a5813cae65c414915e907b9c15c8e6390ad9ba452b77a42cc6271d6d3b36fc62a97477bed12704d09d76993f0757c6cce8711c0f485eda0e5063f5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Release History
2
2
 
3
+ ### 2.15.2 (2023-03-19)
4
+
5
+ #### Bug Fixes
6
+
7
+ * make batch handle publish interval ([#20913](https://github.com/googleapis/google-cloud-ruby/issues/20913))
8
+
9
+ ### 2.15.1 (2023-02-23)
10
+
11
+ #### Documentation
12
+
13
+ * Correct default value for streams ([#20485](https://github.com/googleapis/google-cloud-ruby/issues/20485))
14
+
3
15
  ### 2.15.0 (2023-01-22)
4
16
 
5
17
  #### Features
@@ -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
- until @queue.empty?
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 items_add msg, callback
265
- item = Item.new msg, callback
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
@@ -53,7 +53,7 @@ module Google
53
53
  # @attr_reader [Boolean] message_ordering Whether message ordering has
54
54
  # been enabled.
55
55
  # @attr_reader [Integer] streams The number of concurrent streams to open
56
- # to pull messages from the subscription. Default is 4.
56
+ # to pull messages from the subscription. Default is 2.
57
57
  # @attr_reader [Integer] callback_threads The number of threads used to
58
58
  # handle the received messages. Default is 8.
59
59
  # @attr_reader [Integer] push_threads The number of threads to handle
@@ -937,7 +937,7 @@ module Google
937
937
  # the default message_ordering value for the subscription when this
938
938
  # argument is not provided. See {#reference?}.
939
939
  # @param [Integer] streams The number of concurrent streams to open to
940
- # pull messages from the subscription. Default is 4. Optional.
940
+ # pull messages from the subscription. Default is 2. Optional.
941
941
  # @param [Hash, Integer] inventory The settings to control how received messages are to be handled by the
942
942
  # subscriber. When provided as an Integer instead of a Hash only `max_outstanding_messages` will be set.
943
943
  # Optional.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module PubSub
19
- VERSION = "2.15.0".freeze
19
+ VERSION = "2.15.2".freeze
20
20
  end
21
21
 
22
22
  Pubsub = PubSub unless const_defined? :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.15.0
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-01-23 00:00:00.000000000 Z
12
+ date: 2023-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby