sidekiq-scheduler 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NTgyMGVlOTk3ZGM2ZjQ0ZWI0ZWFkNzViYTU1Mjg2N2ZiZGU4NmI5Mw==
5
- data.tar.gz: !binary |-
6
- ZDA0ZTJmZGU0ZDdlMDBmOGM0ODUxNWIyNDRkMjRjYmQ2ZTMyYjJmMw==
2
+ SHA1:
3
+ metadata.gz: fe9ce1e132d1192efa54cb8ca59db66637bead8b
4
+ data.tar.gz: 067965f503c1a8460b15c46297e991d0476c5a53
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDYxNjQ1ZGVlNGFlNjJiYWIxODQ0NTdkYTEyNDc2YmE4Zjk5MjUzYjdhOTk0
10
- NjY2NDZjOWEyYTAyZTQzYjUyMTE5MmU2MzcxMmFjMzJkZWVkMmZhNzFjOTM4
11
- ZDY4MTJhODMxZjE1MjgyZTgxM2NjMTYxNTJkMmFiMjhhMTk5MjQ=
12
- data.tar.gz: !binary |-
13
- MGU0ZDVmZmE0Yjk3YjRjZTFjOWE1YTA1MmM3M2E1YTI3MDFkODdhZDFlMWUz
14
- MzliNWM1MzAyNWM2ZWY5YzUzMzc2NDNlMzA5M2UzYWFiY2ZhNTA3MmYwOTU0
15
- M2RiYzU1ZTFlOTFjNDdmMDRkZjBiYTcxNWIzYjU3NTAwOTM5M2I=
6
+ metadata.gz: 72d123b5fa650afd26e87611411e30a029c4fd9af6e5f3904e1fde525c4793b61924c5e07005f1553b614bb614243c40406639505abe735613c21546e039240a
7
+ data.tar.gz: a6c10562e33e3c20a865fcbce2ddc280512549482719b2ad0d66750449f3ee9c57bc2c4a604e43055f227dff86f5b3cdeeab042a26d2faccce561daf518b2673
data/README.md CHANGED
@@ -44,7 +44,7 @@ You can add sidekiq-scheduler configuration options to sidekiq.yml config file.
44
44
  Available options are:
45
45
 
46
46
  :schedule: <the schedule to be run>
47
- :dynamic: <if true the schedule can we modified in runtime>
47
+ :dynamic: <if true the schedule can be modified in runtime>
48
48
 
49
49
  ## Scheduled Jobs (Recurring Jobs)
50
50
 
@@ -119,6 +119,18 @@ You can also put your schedule information inside sidekiq.yml and load it with:
119
119
  sidekiq -C ./config/sidekiq.yml
120
120
  ```
121
121
 
122
+ #### The Spring preloader and Testing your initializer via Rails console
123
+
124
+ If you're pulling in your schedule from a YML file via an initializer as shown, be aware that the Spring application preloader included with Rails will interefere with testing via the Rails console.
125
+
126
+ **Spring will not reload initializers** unless the initializer is changed. Therefore, if you're making a change to your YML schedule file and reloading Rails console to see the change, Spring will make it seem like your modified schedule is not being reloaded.
127
+
128
+ To see your updated schedule, be sure to reload Spring by stopping it prior to booting the Rails console.
129
+
130
+ Run `spring stop` to stop Spring.
131
+
132
+ For more information, see [this issue](https://github.com/Moove-it/sidekiq-scheduler/issues/35#issuecomment-48067183) and [Spring's README](https://github.com/rails/spring/blob/master/README.md).
133
+
122
134
  ### Time zones
123
135
 
124
136
  Note that if you use the cron syntax, this will be interpreted as in the server time zone
@@ -164,4 +176,4 @@ MIT License
164
176
 
165
177
  Copyright 2013 Moove-IT
166
178
  Copyright 2012 Morton Jonuschat
167
- Some parts copyright 2010 Ben VandenBos
179
+ Some parts copyright 2010 Ben VandenBos
@@ -1,3 +1,3 @@
1
1
  module SidekiqScheduler
2
- VERSION = '1.0'
3
- end
2
+ VERSION = '1.1'
3
+ end
@@ -7,8 +7,13 @@ module Sidekiq
7
7
  class Scheduler
8
8
  extend Sidekiq::Util
9
9
 
10
+ # We expect rufus jobs to have #params
11
+ Rufus::Scheduler::Job.module_eval do
12
+ alias_method :params, :opts
13
+ end
14
+
10
15
  class << self
11
- # If set, will try to update the schulde in the loop
16
+ # If set, will try to update the schedule in the loop
12
17
  attr_accessor :dynamic
13
18
  end
14
19
 
@@ -77,7 +82,10 @@ module Sidekiq
77
82
  if !config[interval_type].nil? && config[interval_type].length > 0
78
83
  args = self.optionizate_interval_value(config[interval_type])
79
84
 
80
- @@scheduled_jobs[name] = self.rufus_scheduler.send(interval_type, *args) do
85
+ # We want rufus_scheduler to return a job object, not a job id
86
+ opts = { :job => true }
87
+
88
+ @@scheduled_jobs[name] = self.rufus_scheduler.send(interval_type, *args, opts) do
81
89
  logger.info "queueing #{config['class']} (#{name})"
82
90
  config.delete(interval_type)
83
91
  self.handle_errors { self.enqueue_from_config(config) }
@@ -123,8 +131,16 @@ module Sidekiq
123
131
  Sidekiq::Client.push(config)
124
132
  end
125
133
 
134
+ def self.rufus_scheduler_options
135
+ @rufus_scheduler_options ||= {}
136
+ end
137
+
138
+ def self.rufus_scheduler_options=(options)
139
+ @rufus_scheduler_options = options
140
+ end
141
+
126
142
  def self.rufus_scheduler
127
- @rufus_scheduler ||= Rufus::Scheduler.start_new
143
+ @rufus_scheduler ||= Rufus::Scheduler.new rufus_scheduler_options
128
144
  end
129
145
 
130
146
  # Stops old rufus scheduler and creates a new one. Returns the new
@@ -167,4 +183,4 @@ module Sidekiq
167
183
  end
168
184
 
169
185
  end
170
- end
186
+ end
@@ -52,7 +52,7 @@ class ManagerTest < Minitest::Test
52
52
  end
53
53
 
54
54
  it 'config makes it into the rufus_scheduler' do
55
- assert_equal(0, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
55
+ assert_equal(0, Sidekiq::Scheduler.rufus_scheduler.jobs.size)
56
56
  Sidekiq.schedule = {
57
57
  :some_ivar_job => {
58
58
  'cron' => '* * * * *',
@@ -63,11 +63,19 @@ class ManagerTest < Minitest::Test
63
63
 
64
64
  Sidekiq::Scheduler.load_schedule!
65
65
 
66
- assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
66
+ assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.jobs.size)
67
67
  assert Sidekiq::Scheduler.scheduled_jobs.include?(:some_ivar_job)
68
68
  end
69
69
 
70
- # THIS
70
+ it 'can pass options to the Rufus scheduler instance' do
71
+ options = { :lockfile => '/tmp/rufus_lock' }
72
+
73
+ Sidekiq::Scheduler.rufus_scheduler_options = options
74
+ Rufus::Scheduler.expects(:new).with(options)
75
+
76
+ Sidekiq::Scheduler.clear_schedule!
77
+ end
78
+
71
79
  it 'can reload schedule' do
72
80
  Sidekiq::Scheduler.dynamic = true
73
81
  Sidekiq.schedule = {
@@ -99,7 +107,7 @@ class ManagerTest < Minitest::Test
99
107
 
100
108
  Sidekiq::Scheduler.reload_schedule!
101
109
 
102
- assert Sidekiq::Scheduler.scheduled_jobs.include?('some_ivar_job')
110
+ refute Sidekiq::Scheduler.scheduled_jobs.include?('some_ivar_job')
103
111
  assert Sidekiq::Scheduler.scheduled_jobs.include?('some_ivar_job2')
104
112
 
105
113
  assert_equal '/tmp/2', Sidekiq.schedule['some_ivar_job2']['args']
@@ -115,7 +123,7 @@ class ManagerTest < Minitest::Test
115
123
  }
116
124
  )
117
125
 
118
- assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
126
+ assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.jobs.size)
119
127
  assert_equal(1, Sidekiq::Scheduler.scheduled_jobs.size)
120
128
  assert Sidekiq::Scheduler.scheduled_jobs.keys.include?('some_ivar_job')
121
129
  end
@@ -130,7 +138,7 @@ class ManagerTest < Minitest::Test
130
138
  }
131
139
  )
132
140
 
133
- assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
141
+ assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.jobs.size)
134
142
  assert_equal(1, Sidekiq::Scheduler.scheduled_jobs.size)
135
143
  assert Sidekiq::Scheduler.scheduled_jobs.keys.include?('some_ivar_job')
136
144
  assert Sidekiq::Scheduler.scheduled_jobs['some_ivar_job'].params.keys.include?(:first_in)
@@ -146,7 +154,7 @@ class ManagerTest < Minitest::Test
146
154
  }
147
155
  )
148
156
 
149
- assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
157
+ assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.jobs.size)
150
158
  assert_equal(1, Sidekiq::Scheduler.scheduled_jobs.size)
151
159
  assert Sidekiq::Scheduler.scheduled_jobs.keys.include?('some_ivar_job')
152
160
  assert Sidekiq::Scheduler.scheduled_jobs['some_ivar_job'].params.keys.include?(:allow_overlapping)
@@ -161,7 +169,7 @@ class ManagerTest < Minitest::Test
161
169
  }
162
170
  )
163
171
 
164
- assert_equal(0, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
172
+ assert_equal(0, Sidekiq::Scheduler.rufus_scheduler.jobs.size)
165
173
  assert_equal(0, Sidekiq::Scheduler.scheduled_jobs.size)
166
174
  assert !Sidekiq::Scheduler.scheduled_jobs.keys.include?('some_ivar_job')
167
175
  end
@@ -176,7 +184,7 @@ class ManagerTest < Minitest::Test
176
184
  }
177
185
  )
178
186
 
179
- assert_equal(0, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
187
+ assert_equal(0, Sidekiq::Scheduler.rufus_scheduler.jobs.size)
180
188
  assert_equal(0, Sidekiq::Scheduler.scheduled_jobs.size)
181
189
  assert !Sidekiq::Scheduler.scheduled_jobs.keys.include?('some_ivar_job')
182
190
  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: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morton Jonuschat
@@ -9,152 +9,152 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-19 00:00:00.000000000 Z
12
+ date: 2015-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3'
21
- - - ! '>='
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: '2.12'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ~>
28
+ - - "~>"
29
29
  - !ruby/object:Gem::Version
30
30
  version: '3'
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.12'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: redis
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rufus-scheduler
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2'
54
+ version: '3'
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2'
61
+ version: '3'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: multi_json
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1'
69
69
  type: :runtime
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: rake
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '10.0'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: timecop
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: mocha
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: minitest
120
120
  requirement: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '5.0'
125
125
  type: :development
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '5.0'
132
132
  - !ruby/object:Gem::Dependency
133
133
  name: mock_redis
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: simplecov
148
148
  requirement: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  type: :development
154
154
  prerelease: false
155
155
  version_requirements: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  description: Light weight job scheduling extension for Sidekiq that adds support for
@@ -192,25 +192,25 @@ require_paths:
192
192
  - lib
193
193
  required_ruby_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - ! '>='
195
+ - - ">="
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - ! '>='
200
+ - - ">="
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
204
  rubyforge_project:
205
- rubygems_version: 2.2.0
205
+ rubygems_version: 2.2.2
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Light weight job scheduling extension for Sidekiq
209
209
  test_files:
210
+ - test/config.yml
211
+ - test/fake_env.rb
212
+ - test/lib/sidekiq/scheduler_test.rb
210
213
  - test/schedule_test.rb
211
- - test/support/my_worker.rb
212
214
  - test/support/direct_worker.rb
215
+ - test/support/my_worker.rb
213
216
  - test/test_helper.rb
214
- - test/lib/sidekiq/scheduler_test.rb
215
- - test/fake_env.rb
216
- - test/config.yml