sidekiq 3.4.1 → 4.0.2
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/.travis.yml +3 -2
- data/4.0-Upgrade.md +50 -0
- data/COMM-LICENSE +55 -45
- data/Changes.md +85 -1
- data/Ent-Changes.md +79 -0
- data/Gemfile +7 -1
- data/Pro-2.0-Upgrade.md +2 -2
- data/Pro-3.0-Upgrade.md +46 -0
- data/Pro-Changes.md +60 -2
- data/README.md +20 -16
- data/bin/sidekiq +4 -0
- data/bin/sidekiqctl +8 -2
- data/bin/sidekiqload +167 -0
- data/lib/generators/sidekiq/templates/worker_spec.rb.erb +2 -2
- data/lib/generators/sidekiq/templates/worker_test.rb.erb +5 -5
- data/lib/sidekiq/api.rb +43 -33
- data/lib/sidekiq/cli.rb +41 -42
- data/lib/sidekiq/client.rb +5 -10
- data/lib/sidekiq/fetch.rb +35 -111
- data/lib/sidekiq/launcher.rb +102 -42
- data/lib/sidekiq/manager.rb +80 -180
- data/lib/sidekiq/middleware/server/logging.rb +13 -8
- data/lib/sidekiq/middleware/server/retry_jobs.rb +6 -6
- data/lib/sidekiq/processor.rb +126 -97
- data/lib/sidekiq/redis_connection.rb +23 -5
- data/lib/sidekiq/scheduled.rb +47 -26
- data/lib/sidekiq/testing.rb +139 -17
- data/lib/sidekiq/util.rb +20 -0
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web.rb +17 -1
- data/lib/sidekiq/web_helpers.rb +33 -5
- data/lib/sidekiq/worker.rb +16 -0
- data/lib/sidekiq.rb +37 -14
- data/sidekiq.gemspec +10 -11
- data/test/helper.rb +45 -10
- data/test/test_actors.rb +137 -0
- data/test/test_api.rb +417 -384
- data/test/test_cli.rb +29 -59
- data/test/test_client.rb +60 -135
- data/test/test_extensions.rb +29 -23
- data/test/test_fetch.rb +2 -57
- data/test/test_launcher.rb +80 -0
- data/test/test_logging.rb +1 -1
- data/test/test_manager.rb +16 -131
- data/test/test_middleware.rb +3 -5
- data/test/test_processor.rb +110 -76
- data/test/test_rails.rb +21 -0
- data/test/test_redis_connection.rb +0 -1
- data/test/test_retry.rb +114 -162
- data/test/test_scheduled.rb +11 -17
- data/test/test_scheduling.rb +20 -42
- data/test/test_sidekiq.rb +46 -16
- data/test/test_testing.rb +80 -20
- data/test/test_testing_fake.rb +83 -8
- data/test/test_testing_inline.rb +3 -3
- data/test/test_util.rb +16 -0
- data/test/test_web.rb +28 -9
- data/test/test_web_helpers.rb +3 -2
- data/web/assets/images/favicon.ico +0 -0
- data/web/assets/javascripts/application.js +6 -1
- data/web/assets/javascripts/dashboard.js +2 -8
- data/web/assets/javascripts/locales/jquery.timeago.pt-br.js +14 -14
- data/web/assets/stylesheets/application.css +33 -56
- data/web/locales/de.yml +1 -1
- data/web/locales/en.yml +2 -0
- data/web/locales/fr.yml +2 -2
- data/web/locales/ja.yml +10 -1
- data/web/locales/{no.yml → nb.yml} +10 -2
- data/web/locales/uk.yml +76 -0
- data/web/views/_footer.erb +2 -7
- data/web/views/_job_info.erb +5 -1
- data/web/views/_nav.erb +2 -2
- data/web/views/_poll_js.erb +5 -0
- data/web/views/{_poll.erb → _poll_link.erb} +0 -3
- data/web/views/busy.erb +2 -1
- data/web/views/dead.erb +1 -0
- data/web/views/layout.erb +2 -0
- data/web/views/morgue.erb +3 -0
- data/web/views/queue.erb +1 -0
- data/web/views/queues.erb +1 -0
- data/web/views/retries.erb +3 -0
- data/web/views/retry.erb +1 -0
- data/web/views/scheduled.erb +1 -0
- data/web/views/scheduled_job_info.erb +1 -0
- metadata +75 -55
- data/lib/sidekiq/actor.rb +0 -39
- data/test/test_worker_generator.rb +0 -17
data/test/test_actors.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'sidekiq/cli'
|
3
|
+
require 'sidekiq/fetch'
|
4
|
+
require 'sidekiq/scheduled'
|
5
|
+
require 'sidekiq/processor'
|
6
|
+
|
7
|
+
class TestActors < Sidekiq::Test
|
8
|
+
class JoeWorker
|
9
|
+
include Sidekiq::Worker
|
10
|
+
def perform(slp)
|
11
|
+
raise "boom" if slp == "boom"
|
12
|
+
sleep(slp) if slp > 0
|
13
|
+
$count += 1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'threads' do
|
18
|
+
before do
|
19
|
+
Sidekiq.redis {|c| c.flushdb}
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'scheduler' do
|
23
|
+
it 'can start and stop' do
|
24
|
+
f = Sidekiq::Scheduled::Poller.new
|
25
|
+
f.start
|
26
|
+
f.terminate
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can schedule' do
|
30
|
+
ss = Sidekiq::ScheduledSet.new
|
31
|
+
q = Sidekiq::Queue.new
|
32
|
+
|
33
|
+
JoeWorker.perform_in(0.01, 0)
|
34
|
+
|
35
|
+
assert_equal 0, q.size
|
36
|
+
assert_equal 1, ss.size
|
37
|
+
|
38
|
+
sleep 0.015
|
39
|
+
s = Sidekiq::Scheduled::Poller.new
|
40
|
+
s.enqueue
|
41
|
+
assert_equal 1, q.size
|
42
|
+
assert_equal 0, ss.size
|
43
|
+
s.terminate
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'processor' do
|
48
|
+
before do
|
49
|
+
$count = 0
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can start and stop' do
|
53
|
+
f = Sidekiq::Processor.new(Mgr.new)
|
54
|
+
f.terminate
|
55
|
+
end
|
56
|
+
|
57
|
+
class Mgr
|
58
|
+
attr_reader :latest_error
|
59
|
+
attr_reader :mutex
|
60
|
+
attr_reader :cond
|
61
|
+
def initialize
|
62
|
+
@mutex = ::Mutex.new
|
63
|
+
@cond = ::ConditionVariable.new
|
64
|
+
end
|
65
|
+
def processor_died(inst, err)
|
66
|
+
@latest_error = err
|
67
|
+
@mutex.synchronize do
|
68
|
+
@cond.signal
|
69
|
+
end
|
70
|
+
end
|
71
|
+
def processor_stopped(inst)
|
72
|
+
@mutex.synchronize do
|
73
|
+
@cond.signal
|
74
|
+
end
|
75
|
+
end
|
76
|
+
def options
|
77
|
+
{ :concurrency => 3, :queues => ['default'] }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'can process' do
|
82
|
+
mgr = Mgr.new
|
83
|
+
|
84
|
+
p = Sidekiq::Processor.new(mgr)
|
85
|
+
JoeWorker.perform_async(0)
|
86
|
+
|
87
|
+
a = $count
|
88
|
+
p.process_one
|
89
|
+
b = $count
|
90
|
+
assert_equal a + 1, b
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'deals with errors' do
|
94
|
+
mgr = Mgr.new
|
95
|
+
|
96
|
+
p = Sidekiq::Processor.new(mgr)
|
97
|
+
JoeWorker.perform_async("boom")
|
98
|
+
q = Sidekiq::Queue.new
|
99
|
+
assert_equal 1, q.size
|
100
|
+
|
101
|
+
a = $count
|
102
|
+
mgr.mutex.synchronize do
|
103
|
+
p.start
|
104
|
+
mgr.cond.wait(mgr.mutex)
|
105
|
+
end
|
106
|
+
b = $count
|
107
|
+
assert_equal a, b
|
108
|
+
|
109
|
+
sleep 0.001
|
110
|
+
assert_equal false, p.thread.status
|
111
|
+
p.terminate(true)
|
112
|
+
refute_nil mgr.latest_error
|
113
|
+
assert_equal RuntimeError, mgr.latest_error.class
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'gracefully kills' do
|
117
|
+
mgr = Mgr.new
|
118
|
+
|
119
|
+
p = Sidekiq::Processor.new(mgr)
|
120
|
+
JoeWorker.perform_async(1)
|
121
|
+
q = Sidekiq::Queue.new
|
122
|
+
assert_equal 1, q.size
|
123
|
+
|
124
|
+
a = $count
|
125
|
+
p.start
|
126
|
+
sleep(0.02)
|
127
|
+
p.terminate
|
128
|
+
p.kill(true)
|
129
|
+
|
130
|
+
b = $count
|
131
|
+
assert_equal a, b
|
132
|
+
assert_equal false, p.thread.status
|
133
|
+
refute mgr.latest_error, mgr.latest_error.to_s
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|