shoryuken 3.1.10 → 3.1.11
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/lib/shoryuken/fetcher.rb +27 -6
- data/lib/shoryuken/manager.rb +4 -1
- data/lib/shoryuken/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 790d69004ca82f39b30f5c8bc94a22666c5d4dae
|
4
|
+
data.tar.gz: 64d8533b1e113cf735d235b39390096e4fe66501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fb9d015a01aef9d4f0288872e52ec05302f18d74594080b8c8220669fb5ccf822fff031bd36ddd94094371f471c6af95b253217ef3ee5a5ebc76979f13b1289
|
7
|
+
data.tar.gz: 0a00108dbbbf108a98f2d571d6635f8cf49c7230608b3d9c776a770f6c3cc61b6ccdee9a162c05d7dfa41e7921ef1756cfd546fe285bfd0ccb8e874fdb0699b8
|
data/CHANGELOG.md
CHANGED
data/lib/shoryuken/fetcher.rb
CHANGED
@@ -9,20 +9,41 @@ module Shoryuken
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def fetch(queue, limit)
|
12
|
-
|
12
|
+
fetch_with_auto_retry(3) do
|
13
|
+
started_at = Time.now
|
13
14
|
|
14
|
-
|
15
|
+
logger.debug { "Looking for new messages in #{queue}" }
|
15
16
|
|
16
|
-
|
17
|
+
sqs_msgs = Array(receive_messages(queue, [FETCH_LIMIT, limit].min))
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
logger.info { "Found #{sqs_msgs.size} messages for #{queue.name}" } unless sqs_msgs.empty?
|
20
|
+
logger.debug { "Fetcher for #{queue} completed in #{elapsed(started_at)} ms" }
|
20
21
|
|
21
|
-
|
22
|
+
sqs_msgs
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
25
27
|
|
28
|
+
def fetch_with_auto_retry(max_attempts, &block)
|
29
|
+
attempts = 0
|
30
|
+
|
31
|
+
begin
|
32
|
+
yield
|
33
|
+
rescue => ex
|
34
|
+
# Tries to auto retry connectivity errors
|
35
|
+
raise if attempts >= max_attempts
|
36
|
+
|
37
|
+
attempts += 1
|
38
|
+
|
39
|
+
logger.debug { "Retrying fetch attempt #{attempts} for #{ex.message}" }
|
40
|
+
|
41
|
+
sleep((1..5).to_a.sample)
|
42
|
+
|
43
|
+
retry
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
26
47
|
def receive_messages(queue, limit)
|
27
48
|
options = receive_options(queue)
|
28
49
|
|
data/lib/shoryuken/manager.rb
CHANGED
@@ -12,6 +12,7 @@ module Shoryuken
|
|
12
12
|
@max_processors = concurrency
|
13
13
|
@busy_processors = Concurrent::AtomicFixnum.new(0)
|
14
14
|
@executor = executor
|
15
|
+
@running = Concurrent::AtomicBoolean.new(true)
|
15
16
|
end
|
16
17
|
|
17
18
|
def start
|
@@ -21,7 +22,7 @@ module Shoryuken
|
|
21
22
|
private
|
22
23
|
|
23
24
|
def running?
|
24
|
-
@executor.running?
|
25
|
+
@running.true? && @executor.running?
|
25
26
|
end
|
26
27
|
|
27
28
|
def dispatch_loop
|
@@ -104,6 +105,8 @@ module Shoryuken
|
|
104
105
|
logger.error { ex.backtrace.join("\n") } unless ex.backtrace.nil?
|
105
106
|
|
106
107
|
Process.kill('USR1', Process.pid)
|
108
|
+
|
109
|
+
@running.make_false
|
107
110
|
end
|
108
111
|
end
|
109
112
|
end
|
data/lib/shoryuken/version.rb
CHANGED