sidekiq 4.2.5 → 4.2.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sidekiq might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Changes.md +5 -0
- data/README.md +2 -1
- data/bin/sidekiqload +0 -13
- data/lib/sidekiq.rb +1 -0
- data/lib/sidekiq/processor.rb +17 -14
- data/lib/sidekiq/rails.rb +18 -1
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/helpers.rb +1 -0
- data/test/test_processor.rb +21 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dca1b4492db20ca793becbe891322c358858157
|
4
|
+
data.tar.gz: 89782986b48def18330d996488e4b823946d5963
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ff8bfb9436c9508bfbf4d72d66156f940fa4372ae5237124442fc80ef21dd51237b44c3fc8aafab6f798f2b1576f09522ce60ade66748566df5c7c392fc7eb
|
7
|
+
data.tar.gz: 0e21ba4873492e74370b62b4cec47a38383115cc85f9a25b4b695ec54e392fea6f771580e315c8037eb78a0d1309651a08849aea4ea5ec378811650a55237377
|
data/Changes.md
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,8 @@ Getting Started
|
|
50
50
|
-----------------
|
51
51
|
|
52
52
|
See the [Getting Started wiki page](https://github.com/mperham/sidekiq/wiki/Getting-Started) and follow the simple setup process.
|
53
|
-
You can watch [
|
53
|
+
You can watch [this Youtube playlist](https://www.youtube.com/playlist?list=PLjeHh2LSCFrWGT5uVjUuFKAcrcj5kSai1) to learn all about
|
54
|
+
Sidekiq and see its features in action. Here's the Web UI:
|
54
55
|
|
55
56
|
![Web UI](https://github.com/mperham/sidekiq/raw/master/examples/web-ui.png)
|
56
57
|
|
data/bin/sidekiqload
CHANGED
@@ -12,19 +12,6 @@ require_relative '../lib/sidekiq/launcher'
|
|
12
12
|
|
13
13
|
include Sidekiq::Util
|
14
14
|
|
15
|
-
# brew tap shopify/shopify
|
16
|
-
# brew install toxiproxy
|
17
|
-
# gem install toxiproxy
|
18
|
-
require 'toxiproxy'
|
19
|
-
# simulate a non-localhost network for realer-world conditions.
|
20
|
-
# adding 1ms of network latency has an ENORMOUS impact on benchmarks
|
21
|
-
Toxiproxy.populate([{
|
22
|
-
"name": "redis",
|
23
|
-
"listen": "127.0.0.1:6380",
|
24
|
-
"upstream": "127.0.0.1:6379"
|
25
|
-
}])
|
26
|
-
|
27
|
-
|
28
15
|
Sidekiq.configure_server do |config|
|
29
16
|
#config.options[:concurrency] = 1
|
30
17
|
config.redis = { driver: :hiredis, db: 13, port: 6380 }
|
data/lib/sidekiq.rb
CHANGED
data/lib/sidekiq/processor.rb
CHANGED
@@ -37,6 +37,7 @@ module Sidekiq
|
|
37
37
|
@thread = nil
|
38
38
|
@strategy = (mgr.options[:fetch] || Sidekiq::BasicFetch).new(mgr.options)
|
39
39
|
@reloader = Sidekiq.options[:reloader]
|
40
|
+
@executor = Sidekiq.options[:executor]
|
40
41
|
end
|
41
42
|
|
42
43
|
def terminate(wait=false)
|
@@ -121,19 +122,21 @@ module Sidekiq
|
|
121
122
|
|
122
123
|
ack = false
|
123
124
|
begin
|
125
|
+
job_hash = Sidekiq.load_json(jobstr)
|
124
126
|
@reloader.call do
|
125
|
-
|
126
|
-
klass = job['class'.freeze].constantize
|
127
|
+
klass = job_hash['class'.freeze].constantize
|
127
128
|
worker = klass.new
|
128
|
-
worker.jid =
|
129
|
-
|
130
|
-
stats(worker,
|
131
|
-
Sidekiq.server_middleware.invoke(worker,
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
129
|
+
worker.jid = job_hash['jid'.freeze]
|
130
|
+
|
131
|
+
stats(worker, job_hash, queue) do
|
132
|
+
Sidekiq.server_middleware.invoke(worker, job_hash, queue) do
|
133
|
+
@executor.call do
|
134
|
+
# Only ack if we either attempted to start this job or
|
135
|
+
# successfully completed it. This prevents us from
|
136
|
+
# losing jobs if a middleware raises an exception before yielding
|
137
|
+
ack = true
|
138
|
+
execute_job(worker, cloned(job_hash['args'.freeze]))
|
139
|
+
end
|
137
140
|
end
|
138
141
|
end
|
139
142
|
ack = true
|
@@ -144,7 +147,7 @@ module Sidekiq
|
|
144
147
|
# we didn't properly finish it.
|
145
148
|
ack = false
|
146
149
|
rescue Exception => ex
|
147
|
-
handle_exception(ex, { :context => "Job raised exception", :job =>
|
150
|
+
handle_exception(ex, { :context => "Job raised exception", :job => job_hash, :jobstr => jobstr })
|
148
151
|
raise
|
149
152
|
ensure
|
150
153
|
work.acknowledge if ack
|
@@ -163,9 +166,9 @@ module Sidekiq
|
|
163
166
|
PROCESSED = Concurrent::AtomicFixnum.new
|
164
167
|
FAILURE = Concurrent::AtomicFixnum.new
|
165
168
|
|
166
|
-
def stats(worker,
|
169
|
+
def stats(worker, job_hash, queue)
|
167
170
|
tid = thread_identity
|
168
|
-
WORKER_STATE[tid] = {:queue => queue, :payload => cloned(
|
171
|
+
WORKER_STATE[tid] = {:queue => queue, :payload => cloned(job_hash), :run_at => Time.now.to_i }
|
169
172
|
|
170
173
|
begin
|
171
174
|
yield
|
data/lib/sidekiq/rails.rb
CHANGED
@@ -67,15 +67,32 @@ module Sidekiq
|
|
67
67
|
# The reloader API has proven to be troublesome under load in production.
|
68
68
|
# We won't use it at all when classes are cached, see #3154
|
69
69
|
Sidekiq.logger.debug { "Autoload disabled in #{::Rails.env}, Sidekiq will not reload changed classes" }
|
70
|
+
Sidekiq.options[:executor] = Sidekiq::Rails::Executor.new
|
70
71
|
else
|
72
|
+
Sidekiq.logger.debug { "Enabling Rails 5+ live code reloading, so hot!" }
|
71
73
|
Sidekiq.options[:reloader] = Sidekiq::Rails::Reloader.new
|
72
74
|
end
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
78
|
+
class Executor
|
79
|
+
def initialize(app = ::Rails.application)
|
80
|
+
@app = app
|
81
|
+
end
|
82
|
+
|
83
|
+
def call
|
84
|
+
@app.executor.wrap do
|
85
|
+
yield
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def inspect
|
90
|
+
"#<Sidekiq::Rails::Executor @app=#{@app.class.name}>"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
76
94
|
class Reloader
|
77
95
|
def initialize(app = ::Rails.application)
|
78
|
-
Sidekiq.logger.debug "Enabling Rails 5+ live code reloading, so hot!" unless app.config.cache_classes
|
79
96
|
@app = app
|
80
97
|
end
|
81
98
|
|
data/lib/sidekiq/version.rb
CHANGED
data/lib/sidekiq/web/helpers.rb
CHANGED
data/test/test_processor.rb
CHANGED
@@ -67,7 +67,11 @@ class TestProcessor < Sidekiq::Test
|
|
67
67
|
|
68
68
|
describe 'exception handling' do
|
69
69
|
let(:errors) { [] }
|
70
|
-
let(:error_handler)
|
70
|
+
let(:error_handler) do
|
71
|
+
proc do |exception, context|
|
72
|
+
errors << { exception: exception, context: context }
|
73
|
+
end
|
74
|
+
end
|
71
75
|
|
72
76
|
before do
|
73
77
|
Sidekiq.error_handlers << error_handler
|
@@ -78,24 +82,34 @@ class TestProcessor < Sidekiq::Test
|
|
78
82
|
end
|
79
83
|
|
80
84
|
it 'handles exceptions raised by the job' do
|
81
|
-
|
85
|
+
job_hash = { 'class' => MockWorker.to_s, 'args' => ['boom'] }
|
86
|
+
msg = Sidekiq.dump_json(job_hash)
|
87
|
+
job = work(msg)
|
82
88
|
begin
|
83
|
-
@processor.
|
89
|
+
@processor.instance_variable_set(:'@job', job)
|
90
|
+
@processor.process(job)
|
84
91
|
rescue TestException
|
85
92
|
end
|
86
93
|
assert_equal 1, errors.count
|
87
|
-
assert_instance_of TestException, errors.first
|
94
|
+
assert_instance_of TestException, errors.first[:exception]
|
95
|
+
assert_equal msg, errors.first[:context][:jobstr]
|
96
|
+
assert_equal job_hash, errors.first[:context][:job]
|
88
97
|
end
|
89
98
|
|
90
99
|
it 'handles exceptions raised by the reloader' do
|
91
|
-
|
100
|
+
job_hash = { 'class' => MockWorker.to_s, 'args' => ['boom'] }
|
101
|
+
msg = Sidekiq.dump_json(job_hash)
|
92
102
|
@processor.instance_variable_set(:'@reloader', proc { raise TEST_EXCEPTION })
|
103
|
+
job = work(msg)
|
93
104
|
begin
|
94
|
-
@processor.
|
105
|
+
@processor.instance_variable_set(:'@job', job)
|
106
|
+
@processor.process(job)
|
95
107
|
rescue TestException
|
96
108
|
end
|
97
109
|
assert_equal 1, errors.count
|
98
|
-
assert_instance_of TestException, errors.first
|
110
|
+
assert_instance_of TestException, errors.first[:exception]
|
111
|
+
assert_equal msg, errors.first[:context][:jobstr]
|
112
|
+
assert_equal job_hash, errors.first[:context][:job]
|
99
113
|
end
|
100
114
|
end
|
101
115
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|