shoryuken 5.3.0 → 5.3.1

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: 9f4f8cbfdd04c4d39b7f672c549b0d112f64c99a8df4807b83083b57dab8addd
4
- data.tar.gz: 0cfeaef14f59567382eefacb342be547a43f7dc7a118a3f824a6bdc88710ceea
3
+ metadata.gz: c730786f3c97f263b00320693e0ea95af12495bb83805a39461de93b526b4d2a
4
+ data.tar.gz: a7a7fbb4bd5a1c006c1573261c607c6c77968575af901a8671dea4da6e4282c5
5
5
  SHA512:
6
- metadata.gz: 0ee996f0a835c46c50adaef43f413374505df454e8e696c5a1faaefdd9c28a4ed7922f620b56f800a3aad152881c66dd812bad573fec91f9d2ed9bd168c468f8
7
- data.tar.gz: 9208b28922188d06f60ade86d0c53d56c6bedbc8577e908d5aa4a819c23cc13889fdea5dcb8875608495f2bb785f3b198bddbdb4fd93f3d6f7fa53d2f9cfec3f
6
+ metadata.gz: 3bc9237605e5f9667f0e22bdae6ca1553b2f2a08357f2f7da465fa4f812d3abcafd6ef21c05ef553dac13dcb405fa658d13bada5be235743974978fc7829b6d2
7
+ data.tar.gz: 54737eb8fc32b4a486d62f1ef626336e0493ae70475efb1a99e163ebd960d2e38c99506ccf8cafcd3502bd52a2279619601150634e7dbf3134b38913bb0283e8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [v5.3.1] - 2022-01-07
2
+
3
+ - (Bugfix) Fix issue where, when using the TSTP or USR1 signals for soft shutdowns, it was possible for shoryuken to terminate without first attempting to handle all messages it fetched from SQS
4
+ - [#676](https://github.com/ruby-shoryuken/shoryuken/pull/676)
5
+
1
6
  ## [v5.3.0] - 2021-10-31
2
7
 
3
8
  - (Refactor) Use Forwardable within Message to avoid method boilerplate
@@ -28,6 +28,9 @@ module Shoryuken
28
28
 
29
29
  initiate_stop
30
30
 
31
+ stop_new_dispatching
32
+ await_dispatching_in_progress
33
+
31
34
  executor.shutdown
32
35
  executor.wait_for_termination
33
36
  end
@@ -41,6 +44,14 @@ module Shoryuken
41
44
 
42
45
  private
43
46
 
47
+ def stop_new_dispatching
48
+ @managers.each(&:stop_new_dispatching)
49
+ end
50
+
51
+ def await_dispatching_in_progress
52
+ @managers.each(&:await_dispatching_in_progress)
53
+ end
54
+
44
55
  def executor
45
56
  @_executor ||= Shoryuken.launcher_executor || Concurrent.global_io_executor
46
57
  end
@@ -9,13 +9,15 @@ module Shoryuken
9
9
  attr_reader :group
10
10
 
11
11
  def initialize(group, fetcher, polling_strategy, concurrency, executor)
12
- @group = group
13
- @fetcher = fetcher
14
- @polling_strategy = polling_strategy
15
- @max_processors = concurrency
16
- @busy_processors = Concurrent::AtomicFixnum.new(0)
17
- @executor = executor
18
- @running = Concurrent::AtomicBoolean.new(true)
12
+ @group = group
13
+ @fetcher = fetcher
14
+ @polling_strategy = polling_strategy
15
+ @max_processors = concurrency
16
+ @busy_processors = Concurrent::AtomicFixnum.new(0)
17
+ @executor = executor
18
+ @running = Concurrent::AtomicBoolean.new(true)
19
+ @stop_new_dispatching = Concurrent::AtomicBoolean.new(false)
20
+ @dispatching_release_signal = ::Queue.new
19
21
  end
20
22
 
21
23
  def start
@@ -23,6 +25,17 @@ module Shoryuken
23
25
  dispatch_loop
24
26
  end
25
27
 
28
+ def stop_new_dispatching
29
+ @stop_new_dispatching.make_true
30
+ end
31
+
32
+ def await_dispatching_in_progress
33
+ # There might still be a dispatching on-going, as the response from SQS could take some time
34
+ # We don't want to stop the process before processing incoming messages, as they would stay "in-flight" for some time on SQS
35
+ # We use a queue, as the dispatch_loop is running on another thread, and this is a efficient way of communicating between threads.
36
+ @dispatching_release_signal.pop
37
+ end
38
+
26
39
  def running?
27
40
  @running.true? && @executor.running?
28
41
  end
@@ -30,7 +43,10 @@ module Shoryuken
30
43
  private
31
44
 
32
45
  def dispatch_loop
33
- return unless running?
46
+ if @stop_new_dispatching.true? || !running?
47
+ @dispatching_release_signal << 1
48
+ return
49
+ end
34
50
 
35
51
  @executor.post { dispatch }
36
52
  end
@@ -94,7 +110,6 @@ module Shoryuken
94
110
 
95
111
  def dispatch_single_messages(queue)
96
112
  messages = @fetcher.fetch(queue, ready)
97
-
98
113
  @polling_strategy.messages_found(queue.name, messages.size)
99
114
  messages.each { |message| assign(queue.name, message) }
100
115
  end
@@ -1,3 +1,3 @@
1
1
  module Shoryuken
2
- VERSION = '5.3.0'.freeze
2
+ VERSION = '5.3.1'.freeze
3
3
  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: 5.3.0
4
+ version: 5.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Cantero
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-01 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -199,7 +199,7 @@ homepage: https://github.com/phstc/shoryuken
199
199
  licenses:
200
200
  - LGPL-3.0
201
201
  metadata: {}
202
- post_install_message:
202
+ post_install_message:
203
203
  rdoc_options: []
204
204
  require_paths:
205
205
  - lib
@@ -214,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  requirements: []
217
- rubygems_version: 3.0.1
218
- signing_key:
217
+ rubygems_version: 3.0.3.1
218
+ signing_key:
219
219
  specification_version: 4
220
220
  summary: Shoryuken is a super efficient AWS SQS thread based message processor
221
221
  test_files: