aws-sdk-sqs 1.63.0 → 1.64.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 +5 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-sqs/client.rb +1 -1
- data/lib/aws-sdk-sqs/queue_poller.rb +34 -35
- data/lib/aws-sdk-sqs.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: 68eb8fe977b86cb00d0fc688ebc168d08cff78fdf9a332304fcbc825c7d381cb
|
4
|
+
data.tar.gz: 88fe34be85f87be90ff063d796ec49a42098e8882b43cefede85feeb324ef5a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02289264a550230e36c1c9d0cb73a532ca0a2fc5c6ff550fb6390dd7d21c99f77f042fc99153605deaad2a7c945a8b963af34c5dfcf0e96357f83eeea79ba3c1'
|
7
|
+
data.tar.gz: 976aee45c5cb6a9db8d884e4f8abb44807aca6b6c567b3815565864a24e7e775ee32bc3fa23a052a8b8ca378cf7266e79ea0d6539ab32f97ede21f4aa1ad6b71
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.64.0
|
data/lib/aws-sdk-sqs/client.rb
CHANGED
@@ -4,7 +4,6 @@ require 'set'
|
|
4
4
|
|
5
5
|
module Aws
|
6
6
|
module SQS
|
7
|
-
|
8
7
|
# A utility class for long polling messages in a loop. **Messages are
|
9
8
|
# automatically deleted from the queue at the end of the given block.**
|
10
9
|
#
|
@@ -203,7 +202,6 @@ module Aws
|
|
203
202
|
# ```
|
204
203
|
#
|
205
204
|
class QueuePoller
|
206
|
-
|
207
205
|
# @param [String] queue_url
|
208
206
|
# @option options [Client] :client
|
209
207
|
# @option (see #poll)
|
@@ -333,7 +331,7 @@ module Aws
|
|
333
331
|
loop do
|
334
332
|
messages = get_messages(config, stats)
|
335
333
|
if messages.empty?
|
336
|
-
check_idle_timeout(config, stats
|
334
|
+
check_idle_timeout(config, stats)
|
337
335
|
else
|
338
336
|
process_messages(config, stats, messages, &block)
|
339
337
|
end
|
@@ -348,21 +346,21 @@ module Aws
|
|
348
346
|
# `#receipt_handle`.
|
349
347
|
# @param [Integer] seconds
|
350
348
|
def change_message_visibility_timeout(message, seconds)
|
351
|
-
@client.change_message_visibility(
|
349
|
+
@client.change_message_visibility(
|
352
350
|
queue_url: @queue_url,
|
353
351
|
receipt_handle: message.receipt_handle,
|
354
|
-
visibility_timeout: seconds
|
355
|
-
|
352
|
+
visibility_timeout: seconds
|
353
|
+
)
|
356
354
|
end
|
357
355
|
|
358
356
|
# @note This method should be called from inside a {#poll} block.
|
359
357
|
# @param [#receipt_handle] message An object that responds to
|
360
358
|
# `#receipt_handle`.
|
361
359
|
def delete_message(message)
|
362
|
-
@client.delete_message(
|
360
|
+
@client.delete_message(
|
363
361
|
queue_url: @queue_url,
|
364
|
-
receipt_handle: message.receipt_handle
|
365
|
-
|
362
|
+
receipt_handle: message.receipt_handle
|
363
|
+
)
|
366
364
|
end
|
367
365
|
|
368
366
|
# @note This method should be called from inside a {#poll} block.
|
@@ -372,16 +370,16 @@ module Aws
|
|
372
370
|
def delete_messages(messages)
|
373
371
|
@client.delete_message_batch(
|
374
372
|
queue_url: @queue_url,
|
375
|
-
entries: messages.map
|
373
|
+
entries: messages.map do |msg|
|
376
374
|
{ id: msg.message_id, receipt_handle: msg.receipt_handle }
|
377
|
-
|
375
|
+
end
|
378
376
|
)
|
379
377
|
end
|
380
378
|
|
381
379
|
private
|
382
380
|
|
383
381
|
def get_messages(config, stats)
|
384
|
-
config.before_request
|
382
|
+
config.before_request&.call(stats)
|
385
383
|
messages = send_request(config).messages
|
386
384
|
stats.request_count += 1
|
387
385
|
messages
|
@@ -392,17 +390,22 @@ module Aws
|
|
392
390
|
@client.receive_message(params)
|
393
391
|
end
|
394
392
|
|
395
|
-
def check_idle_timeout(config, stats
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
393
|
+
def check_idle_timeout(config, stats)
|
394
|
+
return unless config.idle_timeout
|
395
|
+
|
396
|
+
since = stats.last_message_received_at || stats.polling_started_at
|
397
|
+
idle_time = Time.now - since
|
398
|
+
throw :stop_polling if idle_time > config.idle_timeout
|
401
399
|
end
|
402
400
|
|
403
401
|
def process_messages(config, stats, messages, &block)
|
404
402
|
stats.received_message_count += messages.count
|
405
403
|
stats.last_message_received_at = Time.now
|
404
|
+
|
405
|
+
# duplicated messages will have a different receipt handle
|
406
|
+
# so we need to provide the most recent receipt to
|
407
|
+
# delete a batch - thus, filtering below by message_id
|
408
|
+
messages = messages.reverse.uniq(&:message_id).reverse!
|
406
409
|
catch(:skip_delete) do
|
407
410
|
yield_messages(config, messages, stats, &block)
|
408
411
|
delete_messages(messages) unless config.skip_delete
|
@@ -421,7 +424,6 @@ module Aws
|
|
421
424
|
|
422
425
|
# Statistics tracked client-side by the {QueuePoller}.
|
423
426
|
class PollerStats
|
424
|
-
|
425
427
|
def initialize
|
426
428
|
@request_count = 0
|
427
429
|
@received_message_count = 0
|
@@ -444,27 +446,25 @@ module Aws
|
|
444
446
|
|
445
447
|
# @return [Time,nil]
|
446
448
|
attr_accessor :polling_stopped_at
|
447
|
-
|
448
449
|
end
|
449
450
|
|
450
451
|
# A read-only set of configuration used by the QueuePoller.
|
451
452
|
class PollerConfig
|
452
|
-
|
453
453
|
# @api private
|
454
|
-
CONFIG_OPTIONS = Set.new
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
]
|
454
|
+
CONFIG_OPTIONS = Set.new %i[
|
455
|
+
idle_timeout
|
456
|
+
skip_delete
|
457
|
+
before_request
|
458
|
+
]
|
459
459
|
|
460
460
|
# @api private
|
461
|
-
PARAM_OPTIONS = Set.new
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
]
|
461
|
+
PARAM_OPTIONS = Set.new %i[
|
462
|
+
wait_time_seconds
|
463
|
+
max_number_of_messages
|
464
|
+
visibility_timeout
|
465
|
+
attribute_names
|
466
|
+
message_attribute_names
|
467
|
+
]
|
468
468
|
|
469
469
|
# @return [Integer,nil]
|
470
470
|
attr_reader :idle_timeout
|
@@ -487,7 +487,7 @@ module Aws
|
|
487
487
|
max_number_of_messages: 1,
|
488
488
|
visibility_timeout: nil,
|
489
489
|
attribute_names: ['All'],
|
490
|
-
message_attribute_names: ['All']
|
490
|
+
message_attribute_names: ['All']
|
491
491
|
}
|
492
492
|
options.each do |opt_name, value|
|
493
493
|
if CONFIG_OPTIONS.include?(opt_name)
|
@@ -522,7 +522,6 @@ module Aws
|
|
522
522
|
PARAM_OPTIONS.each { |key| hash[key] = @request_params[key] }
|
523
523
|
hash
|
524
524
|
end
|
525
|
-
|
526
525
|
end
|
527
526
|
end
|
528
527
|
end
|
data/lib/aws-sdk-sqs.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-sqs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.64.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|