sidekiq-scheduler 2.0.5 → 2.0.6

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: c13477c36de16f83f295c07f237a6182a2e8b422
4
- data.tar.gz: 00bd5143e5c9a63038f4aa5ec879e9d1cb5d0389
3
+ metadata.gz: d2b640d812a1bd5a97323ddcc891c3b4322bc5f8
4
+ data.tar.gz: 8d1d6592c877a503f3167fdb91cecced8bebead1
5
5
  SHA512:
6
- metadata.gz: dab3552b21945d9fca703a2aa97de4ca0750b15236bffb95b80af82f14c9e10a8d1a5e2e0011105cdf6a47f51e63737cbb5293cfb8689faa16fce2fb4ad41a8f
7
- data.tar.gz: 9db739424af1df7bef42f4bb418a2282c6962f0f1392da13dbe8e19a57bbd6587cb73888d714e2950669997a09c944cfb552350f8ca255b2af7a09c9b829e806
6
+ metadata.gz: 80c12e6687d4251e579d2d7e802e7721f7d9fe6288689f45684448243e2c0091742910a87b57ae306fe4fe0a5a925bbe1fa8b0e7a60c67be62be139e547d2028
7
+ data.tar.gz: 1d25189e230f7f93bc66fe347326e925c868f8bc967ce5f5211c05aa37ba2f54030732f236e0521621da06af63bd27192ed3beccb6a76baee46c82e4ab8f77e7
data/README.md CHANGED
@@ -58,6 +58,8 @@ Available options are:
58
58
  :schedule: <the schedule to be run>
59
59
  :dynamic: <if true the schedule can be modified in runtime>
60
60
  :enabled: <enables scheduler if true [true by default]>
61
+ :scheduler:
62
+ :listened_queues_only: <push jobs whose queue is being listened by sidekiq [false by default]>
61
63
 
62
64
  ## Manage tasks from Unicorn/Rails server
63
65
 
@@ -138,14 +140,15 @@ for handling the heavy lifting of the actual scheduling engine.
138
140
  ### Loading the schedule
139
141
 
140
142
  Let's assume your scheduled jobs are defined in a file called "config/scheduler.yml" under your Rails project,
141
- you could create a Rails initializer called "config/initializer/scheduler.rb" which would load the job definitions:
143
+ you could create a Rails initializer called "config/initializers/scheduler.rb" which would load the job definitions:
142
144
 
143
145
  ```ruby
144
146
  require 'sidekiq/scheduler'
145
147
 
146
148
  Sidekiq.configure_server do |config|
147
149
  config.on(:startup) do
148
- Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/scheduler.yml",__FILE__))
150
+ Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/scheduler.yml",__FILE__))
151
+ Sidekiq::Scheduler.reload_schedule!
149
152
  end
150
153
  end
151
154
  ```
@@ -157,9 +160,9 @@ require 'sidekiq/scheduler'
157
160
  Dir[File.expand_path('../lib/workers/*.rb',__FILE__)].each do |file| load file; end
158
161
 
159
162
  Sidekiq.configure_server do |config|
160
-
161
163
  config.on(:startup) do
162
164
  Sidekiq.schedule = YAML.load_file(File.expand_path("../../../config/scheduler.yml",__FILE__))
165
+ Sidekiq::Scheduler.reload_schedule!
163
166
  end
164
167
  end
165
168
  ```
@@ -247,7 +250,7 @@ require 'sidekiq-scheduler/web'
247
250
 
248
251
  ## Credits
249
252
 
250
- This work is a partial port of [resque-scheduler](https://github.com/bvandenbos/resque-scheduler) by Ben VandenBos.
253
+ This work is a partial port of [resque-scheduler](https://github.com/bvandenbos/resque-scheduler) by Ben VandenBos.
251
254
  Modified to work with the Sidekiq queueing library by Morton Jonuschat.
252
255
  Scheduling of recurring jobs has been added to v0.4.0, thanks to [Adrian Gomez](https://github.com/adrian-gomez).
253
256
 
@@ -13,11 +13,16 @@ Sidekiq.configure_server do |config|
13
13
  enabled = Sidekiq::Scheduler.enabled
14
14
  enabled = enabled.nil? ? config.options.fetch(:enabled, true) : enabled
15
15
 
16
+ scheduler = config.options.fetch(:scheduler, {})
17
+
18
+ listened_queues_only = Sidekiq::Scheduler.listened_queues_only
19
+ listened_queues_only = listened_queues_only.nil? ? scheduler[:listened_queues_only] : listened_queues_only
20
+
16
21
  scheduler_options = {
17
- scheduler: config.options.fetch(:scheduler, true),
18
22
  dynamic: dynamic,
19
23
  enabled: enabled,
20
- schedule: config.options.fetch(:schedule, nil)
24
+ schedule: config.options.fetch(:schedule, nil),
25
+ listened_queues_only: listened_queues_only
21
26
  }
22
27
 
23
28
  schedule_manager = SidekiqScheduler::Manager.new(scheduler_options)
@@ -17,6 +17,7 @@ module SidekiqScheduler
17
17
  def initialize(options)
18
18
  Sidekiq::Scheduler.enabled = options[:enabled]
19
19
  Sidekiq::Scheduler.dynamic = options[:dynamic]
20
+ Sidekiq::Scheduler.listened_queues_only = options[:listened_queues_only]
20
21
  Sidekiq.schedule = options[:schedule] if options[:schedule]
21
22
  end
22
23
 
@@ -1,5 +1,5 @@
1
1
  module SidekiqScheduler
2
2
 
3
- VERSION = '2.0.5'
3
+ VERSION = '2.0.6'
4
4
 
5
5
  end
@@ -22,6 +22,8 @@ module Sidekiq
22
22
  # Set to update the schedule in runtime in a given time period.
23
23
  attr_accessor :dynamic
24
24
 
25
+ # Set to schedule jobs only when will be pushed to queues listened by sidekiq
26
+ attr_accessor :listened_queues_only
25
27
  end
26
28
 
27
29
  # the Rufus::Scheduler jobs that are scheduled
@@ -55,10 +57,15 @@ module Sidekiq
55
57
 
56
58
  logger.info 'Schedule empty! Set Sidekiq.schedule' if Sidekiq.schedule.empty?
57
59
 
60
+
58
61
  @@scheduled_jobs = {}
59
62
 
60
63
  Sidekiq.schedule.each do |name, config|
61
- self.load_schedule_job(name, config)
64
+ if !listened_queues_only || enabled_queue?(config['queue'])
65
+ self.load_schedule_job(name, config)
66
+ else
67
+ logger.info { "Ignoring #{name}, job's queue is not enabled." }
68
+ end
62
69
  end
63
70
 
64
71
  Sidekiq.redis { |r| r.del(:schedules_changed) }
@@ -245,5 +252,16 @@ module Sidekiq
245
252
  config
246
253
  end
247
254
 
255
+ # Returns true if a job's queue is being listened on by sidekiq
256
+ #
257
+ # @param [String] job_queue Job's queue name
258
+ #
259
+ # @return [Boolean]
260
+ def self.enabled_queue?(job_queue)
261
+ queues = Sidekiq.options[:queues]
262
+
263
+ queues.empty? || queues.include?(job_queue)
264
+ end
265
+
248
266
  end
249
267
  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.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morton Jonuschat
@@ -9,216 +9,216 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-09 00:00:00.000000000 Z
12
+ date: 2016-03-31 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
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: redis
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '3'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '3'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rufus-scheduler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 3.1.8
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 3.1.8
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: multi_json
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: tilt
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ~>
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '2.0'
76
+ version: 1.4.0
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ~>
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '2.0'
83
+ version: 1.4.0
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ~>
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '10.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ~>
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '10.0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: timecop
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ~>
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ~>
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: mocha
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ~>
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ~>
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rspec
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - '>='
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - '>='
137
+ - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: mock_redis
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ~>
144
+ - - "~>"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ~>
151
+ - - "~>"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: simplecov
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ~>
158
+ - - "~>"
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ~>
165
+ - - "~>"
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: activejob
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - '>='
172
+ - - ">="
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0'
175
175
  type: :development
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - '>='
179
+ - - ">="
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  - !ruby/object:Gem::Dependency
183
183
  name: coveralls
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - '>='
186
+ - - ">="
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
- - - '>='
193
+ - - ">="
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: rack-test
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - '>='
200
+ - - ">="
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - '>='
207
+ - - ">="
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  - !ruby/object:Gem::Dependency
211
211
  name: sinatra
212
212
  requirement: !ruby/object:Gem::Requirement
213
213
  requirements:
214
- - - '>='
214
+ - - ">="
215
215
  - !ruby/object:Gem::Version
216
216
  version: '0'
217
217
  type: :development
218
218
  prerelease: false
219
219
  version_requirements: !ruby/object:Gem::Requirement
220
220
  requirements:
221
- - - '>='
221
+ - - ">="
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  description: Light weight job scheduling extension for Sidekiq that adds support for
@@ -229,18 +229,18 @@ executables: []
229
229
  extensions: []
230
230
  extra_rdoc_files: []
231
231
  files:
232
- - lib/sidekiq/scheduler.rb
232
+ - MIT-LICENSE
233
+ - README.md
234
+ - Rakefile
235
+ - lib/sidekiq-scheduler.rb
233
236
  - lib/sidekiq-scheduler/manager.rb
234
237
  - lib/sidekiq-scheduler/schedule.rb
235
238
  - lib/sidekiq-scheduler/version.rb
236
239
  - lib/sidekiq-scheduler/web.rb
237
- - lib/sidekiq-scheduler.rb
240
+ - lib/sidekiq/scheduler.rb
238
241
  - web/locales/cs.yml
239
242
  - web/locales/en.yml
240
243
  - web/views/recurring_jobs.erb
241
- - MIT-LICENSE
242
- - Rakefile
243
- - README.md
244
244
  homepage: https://github.com/moove-it/sidekiq-scheduler
245
245
  licenses:
246
246
  - MIT
@@ -251,17 +251,17 @@ require_paths:
251
251
  - lib
252
252
  required_ruby_version: !ruby/object:Gem::Requirement
253
253
  requirements:
254
- - - '>='
254
+ - - ">="
255
255
  - !ruby/object:Gem::Version
256
256
  version: '0'
257
257
  required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  requirements:
259
- - - '>='
259
+ - - ">="
260
260
  - !ruby/object:Gem::Version
261
261
  version: '0'
262
262
  requirements: []
263
263
  rubyforge_project:
264
- rubygems_version: 2.0.14
264
+ rubygems_version: 2.4.5.1
265
265
  signing_key:
266
266
  specification_version: 4
267
267
  summary: Light weight job scheduling extension for Sidekiq