sqeduler 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +7 -3
- data/CHANGES.md +4 -0
- data/lib/sqeduler/service.rb +13 -14
- data/lib/sqeduler/version.rb +1 -1
- data/spec/integration_spec.rb +1 -1
- data/spec/service_spec.rb +6 -47
- data/spec/spec_helper.rb +1 -1
- data/spec/worker_spec.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd29046cb516b9fafdbd2ec01a41adb53478cf82
|
4
|
+
data.tar.gz: 739c3c00428e9805ef77f87596a16bd4efe6fdf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da595ba77cd4088ea1b437ff37cd5ab4dc033e28b476e88f3555fa5a421ff8217fbab5b518be48fb71e610c32d1fb67120d6172da838ed099852289b3c4249d2
|
7
|
+
data.tar.gz: 1bcdb26ae008247dc0dca1d079a723c3a031bf7c7e0ffc26d59f56f323b2ec85af51cdda2ae16a9347781cafeee54ab1cc742c872cd9c9ebf1545c447aa0f0b5
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/lib/sqeduler/service.rb
CHANGED
@@ -14,7 +14,6 @@ module Sqeduler
|
|
14
14
|
raise "No config provided" unless config
|
15
15
|
config_sidekiq_server
|
16
16
|
config_sidekiq_client
|
17
|
-
config_scheduler
|
18
17
|
end
|
19
18
|
|
20
19
|
def verify_redis_pool(redis_pool)
|
@@ -33,10 +32,22 @@ module Sqeduler
|
|
33
32
|
::Sidekiq.configure_server do |config|
|
34
33
|
setup_sidekiq_redis(config)
|
35
34
|
if Service.scheduling?
|
35
|
+
logger.info "Initializing Sidekiq::Scheduler with schedule #{::Sqeduler::Service.config.schedule_path}"
|
36
|
+
|
37
|
+
config.on(:startup) do
|
38
|
+
::Sidekiq::Scheduler.rufus_scheduler_options = {
|
39
|
+
:trigger_lock => TriggerLock.new
|
40
|
+
}
|
41
|
+
::Sidekiq.schedule = ::Sqeduler::Service.parse_schedule(::Sqeduler::Service.config.schedule_path)
|
42
|
+
::Sidekiq::Scheduler.reload_schedule!
|
43
|
+
end
|
44
|
+
|
36
45
|
config.on(:shutdown) do
|
37
46
|
# Make sure any scheduling locks are released on shutdown.
|
38
|
-
Sidekiq::Scheduler.rufus_scheduler.stop
|
47
|
+
::Sidekiq::Scheduler.rufus_scheduler.stop
|
39
48
|
end
|
49
|
+
else
|
50
|
+
logger.warn "No schedule_path provided. Not starting Sidekiq::Scheduler."
|
40
51
|
end
|
41
52
|
|
42
53
|
# the server can also enqueue jobs
|
@@ -68,18 +79,6 @@ module Sqeduler
|
|
68
79
|
config.redis = Service.config.redis_hash
|
69
80
|
end
|
70
81
|
|
71
|
-
def config_scheduler
|
72
|
-
if scheduling?
|
73
|
-
logger.info "Initializing Sidekiq::Scheduler with schedule #{config.schedule_path}"
|
74
|
-
::Sidekiq::Scheduler.rufus_scheduler_options = {
|
75
|
-
:trigger_lock => TriggerLock.new
|
76
|
-
}
|
77
|
-
::Sidekiq.schedule = parse_schedule(config.schedule_path)
|
78
|
-
else
|
79
|
-
logger.warn "No schedule_path provided. Not starting Sidekiq::Scheduler."
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
82
|
def parse_schedule(path)
|
84
83
|
raise "Schedule file #{path} does not exist!" unless File.exist?(path)
|
85
84
|
file_contents = File.read(path)
|
data/lib/sqeduler/version.rb
CHANGED
data/spec/integration_spec.rb
CHANGED
data/spec/service_spec.rb
CHANGED
@@ -17,7 +17,7 @@ RSpec.describe Sqeduler::Service do
|
|
17
17
|
|
18
18
|
context "no config provided" do
|
19
19
|
it "should raise" do
|
20
|
-
expect { subject }.to raise_error
|
20
|
+
expect { subject }.to raise_error(RuntimeError, "No config provided")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -38,12 +38,12 @@ RSpec.describe Sqeduler::Service do
|
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "configures the server" do
|
42
42
|
expect(Sidekiq).to receive(:configure_server)
|
43
43
|
subject
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "configures the client" do
|
47
47
|
expect(Sidekiq).to receive(:configure_client)
|
48
48
|
subject
|
49
49
|
end
|
@@ -58,47 +58,6 @@ RSpec.describe Sqeduler::Service do
|
|
58
58
|
expect(client_receiver).to receive(:call)
|
59
59
|
subject
|
60
60
|
end
|
61
|
-
|
62
|
-
context "a schedule_path is provided" do
|
63
|
-
it "starts the scheduler" do
|
64
|
-
expect(Sidekiq).to receive(:"schedule=").with(
|
65
|
-
"FakeWorker" => {
|
66
|
-
"every" => "5s"
|
67
|
-
}
|
68
|
-
)
|
69
|
-
subject
|
70
|
-
expect(Sidekiq::Scheduler.rufus_scheduler_options).to have_key(:trigger_lock)
|
71
|
-
expect(Sidekiq::Scheduler.rufus_scheduler_options[:trigger_lock]).to be_kind_of(
|
72
|
-
Sqeduler::TriggerLock
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
context "a schedule_path is a string" do
|
77
|
-
let(:schedule_filepath) { "./spec/fixtures/schedule.yaml" }
|
78
|
-
|
79
|
-
it "starts the scheduler" do
|
80
|
-
expect(Sidekiq).to receive(:"schedule=").with(
|
81
|
-
"FakeWorker" => {
|
82
|
-
"every" => "5s"
|
83
|
-
}
|
84
|
-
)
|
85
|
-
subject
|
86
|
-
expect(Sidekiq::Scheduler.rufus_scheduler_options).to have_key(:trigger_lock)
|
87
|
-
expect(Sidekiq::Scheduler.rufus_scheduler_options[:trigger_lock]).to be_kind_of(
|
88
|
-
Sqeduler::TriggerLock
|
89
|
-
)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "a schedule_path is not provided" do
|
95
|
-
let(:schedule_filepath) { nil }
|
96
|
-
|
97
|
-
it "does not start the scheduler" do
|
98
|
-
expect(Sidekiq).to_not receive(:"schedule=")
|
99
|
-
subject
|
100
|
-
end
|
101
|
-
end
|
102
61
|
end
|
103
62
|
end
|
104
63
|
|
@@ -134,7 +93,7 @@ RSpec.describe Sqeduler::Service do
|
|
134
93
|
allow_any_instance_of(Redis).to receive(:info).and_return(
|
135
94
|
"redis_version" => "2.6.11"
|
136
95
|
)
|
137
|
-
expect { subject }.to raise_error
|
96
|
+
expect { subject }.to raise_error(RuntimeError, "Must be using redis >= 2.6.12")
|
138
97
|
end
|
139
98
|
end
|
140
99
|
|
@@ -168,7 +127,7 @@ RSpec.describe Sqeduler::Service do
|
|
168
127
|
end
|
169
128
|
|
170
129
|
it "should raise" do
|
171
|
-
expect { described_class.redis_pool }.to raise_error
|
130
|
+
expect { described_class.redis_pool }.to raise_error(RuntimeError, "Must be using redis >= 2.6.12")
|
172
131
|
end
|
173
132
|
end
|
174
133
|
|
@@ -226,7 +185,7 @@ RSpec.describe Sqeduler::Service do
|
|
226
185
|
let(:logger) { nil }
|
227
186
|
|
228
187
|
it "should raise ArgumentError" do
|
229
|
-
expect { subject }.to raise_error(ArgumentError)
|
188
|
+
expect { subject }.to raise_error(ArgumentError, /^No logger provided/)
|
230
189
|
end
|
231
190
|
|
232
191
|
context "in a Rails app" do
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ RSpec.configure do |config|
|
|
12
12
|
config.before(:each) do
|
13
13
|
TEST_REDIS.flushdb
|
14
14
|
Sqeduler::Service.config = nil
|
15
|
-
REDIS_CONFIG
|
15
|
+
stub_const("REDIS_CONFIG", :host => "localhost", :db => 1)
|
16
16
|
end
|
17
17
|
config.disable_monkey_patching!
|
18
18
|
end
|
data/spec/worker_spec.rb
CHANGED
@@ -4,12 +4,12 @@ require "./spec/fixtures/fake_worker"
|
|
4
4
|
|
5
5
|
RSpec.describe Sqeduler::Worker do
|
6
6
|
def verify_callback_occured(file_path, times = 1)
|
7
|
-
expect(File
|
7
|
+
expect(File.exist?(file_path)).to be_truthy
|
8
8
|
expect(File.read(file_path).length).to eq(times)
|
9
9
|
end
|
10
10
|
|
11
11
|
def verify_callback_skipped(file_path)
|
12
|
-
expect(File
|
12
|
+
expect(File.exist?(file_path)).to be_falsey
|
13
13
|
end
|
14
14
|
|
15
15
|
def maybe_cleanup_file(file_path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqeduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Jenkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
version: '0'
|
235
235
|
requirements: []
|
236
236
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.
|
237
|
+
rubygems_version: 2.5.1
|
238
238
|
signing_key:
|
239
239
|
specification_version: 4
|
240
240
|
summary: Common Sidekiq infrastructure for multi-host applications.
|
@@ -254,4 +254,3 @@ test_files:
|
|
254
254
|
- spec/worker/kill_switch_spec.rb
|
255
255
|
- spec/worker/synchronization_spec.rb
|
256
256
|
- spec/worker_spec.rb
|
257
|
-
has_rdoc:
|