shoryuken 3.3.1 → 4.0.0

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
  SHA1:
3
- metadata.gz: 52e12e226493b5e6bd3b03fe20e72704be91e0a3
4
- data.tar.gz: 01307631f8faa8eaec721440afd52ce5fabde0b5
3
+ metadata.gz: ca967b0796d5e97753b9d201edd7aaad2e1d5c44
4
+ data.tar.gz: 4984a4ee2243ba5d8b42bec2e0c0b68e15b92c9f
5
5
  SHA512:
6
- metadata.gz: f9d451c4a642436008d1cdf60edd78d8e251fa56cc8ddc455792a85a997eb2acc601ff8a7743f3bfb5cfeadac5c8a9059490df63b5a2ec1dae3174eb4f868fd5
7
- data.tar.gz: 9da2205a92ff6f92ce6befc0c61de49aa174529d5b704329341dd47e4aaa0a48288678d729c6b3f32695a46560136c5cfc230e7204316d6b9c759972a7a14d36
6
+ metadata.gz: 8143c4a34706093177109f9d822afc711c8c88cd51c2a64653e15b8054794327e59951fccbc5990992b7d568db3cd79a1e23a1a7ec33d7a7c29837e10534f187
7
+ data.tar.gz: 5925db2ddbd791708c59b05a59805ca711bb82c9ef059db849568f8de9fec1619d7b52eab26cced9bb7b7e713ffd11227292c4294bbf642a49e60c35096fcb5d
@@ -1,3 +1,8 @@
1
+ ## [v4.0.0] - 2018-11-01
2
+
3
+ - Process messages to the same message group ID one by one
4
+ - [#530](https://github.com/phstc/shoryuken/pull/530)
5
+
1
6
  ## [v3.3.1] - 2018-10-30
2
7
 
3
8
  - Memoization of boolean causes extra calls to SQS
@@ -47,13 +47,24 @@ module Shoryuken
47
47
  def receive_messages(queue, limit)
48
48
  options = receive_options(queue)
49
49
 
50
- options[:max_number_of_messages] = max_number_of_messages(limit, options)
50
+ shoryuken_queue = Shoryuken::Client.queues(queue.name)
51
+
52
+ # For FIFO queues we want to make sure we process one message per group at the time
53
+ # if we set max_number_of_messages greater than 1,
54
+ # SQS may return more than one message for the same message group
55
+ # since Shoryuken uses threads, it will try to process more than one at once
56
+ # > The message group ID is the tag that specifies that a message belongs to a specific message group.
57
+ # > Messages that belong to the same message group are always processed one by one,
58
+ # > in a strict order relative to the message group
59
+ # > (however, messages that belong to different message groups might be processed out of order).
60
+ # > https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagegroupid-property.html
61
+ options[:max_number_of_messages] = shoryuken_queue.fifo? ? 1 : max_number_of_messages(limit, options)
51
62
  options[:message_attribute_names] = %w[All]
52
63
  options[:attribute_names] = %w[All]
53
64
 
54
65
  options.merge!(queue.options)
55
66
 
56
- Shoryuken::Client.queues(queue.name).receive_messages(options)
67
+ shoryuken_queue.receive_messages(options)
57
68
  end
58
69
 
59
70
  def max_number_of_messages(limit, options)
@@ -1,3 +1,3 @@
1
1
  module Shoryuken
2
- VERSION = '3.3.1'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -4,7 +4,7 @@ require 'shoryuken/fetcher'
4
4
 
5
5
  # rubocop:disable Metrics/BlockLength
6
6
  RSpec.describe Shoryuken::Fetcher do
7
- let(:queue) { instance_double('Shoryuken::Queue') }
7
+ let(:queue) { instance_double('Shoryuken::Queue', fifo?: false) }
8
8
  let(:queue_name) { 'default' }
9
9
  let(:queue_config) { Shoryuken::Polling::QueueConfiguration.new(queue_name, {}) }
10
10
  let(:group) { 'default' }
@@ -100,5 +100,21 @@ RSpec.describe Shoryuken::Fetcher do
100
100
  subject.fetch(queue_config, limit)
101
101
  end
102
102
  end
103
+
104
+ context 'when FIFO' do
105
+ let(:limit) { 10 }
106
+ let(:queue) { instance_double('Shoryuken::Queue', fifo?: true) }
107
+
108
+ it 'polls one message at the time' do
109
+ # see https://github.com/phstc/shoryuken/pull/530
110
+
111
+ allow(Shoryuken::Client).to receive(:queues).with(queue_name).and_return(queue)
112
+ expect(queue).to receive(:receive_messages).with(
113
+ max_number_of_messages: 1, attribute_names: ['All'], message_attribute_names: ['All']
114
+ ).and_return([])
115
+
116
+ subject.fetch(queue_config, limit)
117
+ end
118
+ end
103
119
  end
104
120
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoryuken
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Cantero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-30 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler