sidekiq-scheduler 2.0.0 → 2.0.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
  SHA1:
3
- metadata.gz: 037b6a4d410e4524dbf981cc073d9c30c5e31009
4
- data.tar.gz: 345305609e9b89c755d636c6c9124090be88c777
3
+ metadata.gz: 743371bafeb924ead436bf1af7be4a04d1643c34
4
+ data.tar.gz: 51dd55ce2e46e04c9a7f5ff682f7efb7edb1215d
5
5
  SHA512:
6
- metadata.gz: f4581a66f03bd8c574565f3ea432fc5a179a1a3e28fd3d93c0822f320b36369415c2cb84945599772631b9b4c4828f3f4f8b011144c7ecf516cb4546020066b1
7
- data.tar.gz: 582260da864b28b3f9cf0484012e1356dad92253732f1c404cf2b3fb2971563ed8bc87b9d728848e5e6f80a3fa18e50c8e1a67c87d75cb627f4864f050ca46a0
6
+ metadata.gz: 3a6c82f077edeeee2700ad78fcf0890e5ebfe7f67f649aca84c98de5b0eaa2310bf24438f0d8e4e1f3dc1aaba1b735db5d063a5e61945eab5a4ebef8d59aa15e
7
+ data.tar.gz: 1928654824078d46092657a1e6f3b8033066e889119438afc7c2e48ba7b5c0611dd113c868fa9225274f67f1b26c88125f1531bbbcf603a811464127c66ea176
data/README.md CHANGED
@@ -34,7 +34,7 @@ Scheduled jobs are like cron jobs, recurring on a regular basis.
34
34
 
35
35
  Add this to your Gemfile:
36
36
  ```ruby
37
- gem 'sidekiq-scheduler', '~> 1.2'
37
+ gem 'sidekiq-scheduler', '~> 2.0'
38
38
  ```
39
39
 
40
40
  If you are using rails you are set
@@ -57,7 +57,7 @@ Available options are:
57
57
 
58
58
  :schedule: <the schedule to be run>
59
59
  :dynamic: <if true the schedule can be modified in runtime>
60
- :enabled: <disables scheduler if true [true by default]>
60
+ :enabled: <enables scheduler if true [true by default]>
61
61
 
62
62
  ## Manage tasks from Unicorn/Rails server
63
63
 
@@ -72,16 +72,20 @@ puts "defined?(Rails::Server) is #{defined?(Rails::Server).inspect}"
72
72
  puts "defined?(Unicorn) is #{defined?(Unicorn).inspect}"
73
73
 
74
74
  if Rails.env == 'production' && (defined?(Rails::Server) || defined?(Unicorn))
75
- Sidekiq.schedule = YAML
76
- .load_file(File.expand_path('../../../config/scheduler.yml', __FILE__))
77
- Sidekiq::Scheduler.reload_schedule!
75
+ Sidekiq.configure_server do |config|
76
+
77
+ config.on(:startup) do
78
+ Sidekiq.schedule = YAML
79
+ .load_file(File.expand_path('../../../config/scheduler.yml', __FILE__))
80
+ Sidekiq::Scheduler.reload_schedule!
81
+ end
82
+ end
78
83
  else
79
84
  Sidekiq::Scheduler.enabled = false
80
85
  puts "Sidekiq::Scheduler.enabled is #{Sidekiq::Scheduler.enabled.inspect}"
81
86
  end
82
87
  ```
83
88
 
84
-
85
89
  ## Scheduled Jobs (Recurring Jobs)
86
90
 
87
91
  Scheduled (or recurring) jobs are logically no different than a standard cron
@@ -138,7 +142,12 @@ you could create a Rails initializer called "config/initializer/scheduler.rb" wh
138
142
 
139
143
  ```ruby
140
144
  require 'sidekiq/scheduler'
141
- Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/scheduler.yml",__FILE__))
145
+
146
+ Sidekiq.configure_server do |config|
147
+ config.on(:startup) do
148
+ Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/scheduler.yml",__FILE__))
149
+ end
150
+ end
142
151
  ```
143
152
 
144
153
  If you were running a non Rails project you should add code to load the workers classes before loading the schedule.
@@ -146,7 +155,13 @@ If you were running a non Rails project you should add code to load the workers
146
155
  ```ruby
147
156
  require 'sidekiq/scheduler'
148
157
  Dir[File.expand_path('../lib/workers/*.rb',__FILE__)].each do |file| load file; end
149
- Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/scheduler.yml",__FILE__))
158
+
159
+ Sidekiq.configure_server do |config|
160
+
161
+ config.on(:startup) do
162
+ Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/scheduler.yml",__FILE__))
163
+ end
164
+ end
150
165
  ```
151
166
 
152
167
  You can also put your schedule information inside sidekiq.yml and load it with:
@@ -236,11 +251,6 @@ This work is a partial port of [resque-scheduler](https://github.com/bvandenbos/
236
251
  Modified to work with the Sidekiq queueing library by Morton Jonuschat.
237
252
  Scheduling of recurring jobs has been added to v0.4.0, thanks to [Adrian Gomez](https://github.com/adrian-gomez).
238
253
 
239
- ## Maintainers
240
-
241
- * [Morton Jonuschat](https://github.com/yabawock)
242
- * [Adrian Gomez](https://github.com/adrian-gomez)
243
-
244
254
  ## License
245
255
 
246
256
  MIT License
@@ -37,11 +37,16 @@ module SidekiqScheduler
37
37
  # param, otherwise params is passed in as the only parameter to perform.
38
38
  def schedule=(schedule_hash)
39
39
  schedule_hash = prepare_schedule(schedule_hash)
40
+ to_remove = (get_all_schedules || {}).keys - schedule_hash.keys
40
41
 
41
42
  schedule_hash.each do |name, job_spec|
42
43
  set_schedule(name, job_spec)
43
44
  end
44
45
 
46
+ to_remove.each do |name|
47
+ remove_schedule(name)
48
+ end
49
+
45
50
  @schedule = schedule_hash
46
51
  end
47
52
 
@@ -1,5 +1,5 @@
1
1
  module SidekiqScheduler
2
2
 
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
 
5
5
  end
@@ -76,5 +76,22 @@ class ScheduleTest < Minitest::Test
76
76
  assert_equal nil, job_from_redis_without_decoding(job_id)
77
77
  assert Sidekiq.redis{ |r| r.sismember(:schedules_changed, job_id) }
78
78
  end
79
+
80
+ describe 'schedule update' do
81
+ let(:new_job_id) { 'my_ivar_job_2' }
82
+ let(:new_job_class_id) { 'SomeIvarJob2' }
83
+
84
+ before do
85
+ Sidekiq::Scheduler.dynamic = true
86
+ Sidekiq.schedule = {job_id => cron_hash}
87
+ end
88
+
89
+ it 'schedule= adds new jobs to schedule and remove old ones' do
90
+ Sidekiq.schedule = {new_job_id => cron_hash}
91
+
92
+ assert_equal(cron_hash, job_from_redis(new_job_id))
93
+ assert_equal(nil, job_from_redis_without_decoding(job_id))
94
+ end
95
+ end
79
96
  end
80
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morton Jonuschat
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-26 00:00:00.000000000 Z
12
+ date: 2015-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1'
70
+ - !ruby/object:Gem::Dependency
71
+ name: tilt
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '2.0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '2.0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: rake
72
86
  requirement: !ruby/object:Gem::Requirement