sidekiq-scheduler 1.1 → 1.2

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: fe9ce1e132d1192efa54cb8ca59db66637bead8b
4
- data.tar.gz: 067965f503c1a8460b15c46297e991d0476c5a53
3
+ metadata.gz: 75ecc98109d7528987f25b9f60a8bfa3cb49e627
4
+ data.tar.gz: 3409f6bb8914728dbad69fc302454c8cfc1d85cb
5
5
  SHA512:
6
- metadata.gz: 72d123b5fa650afd26e87611411e30a029c4fd9af6e5f3904e1fde525c4793b61924c5e07005f1553b614bb614243c40406639505abe735613c21546e039240a
7
- data.tar.gz: a6c10562e33e3c20a865fcbce2ddc280512549482719b2ad0d66750449f3ee9c57bc2c4a604e43055f227dff86f5b3cdeeab042a26d2faccce561daf518b2673
6
+ metadata.gz: 2ce177f8c66589464da269a155047d74f76db11ea4b402f9a9fe5c62c8d573220cc72de786ad1f859924b5ce024c98f9494c54fb1261936a45d8ec2ba2c94aae
7
+ data.tar.gz: 4d6cfa0dbe517086e9cd6ff51e6bdc4164159f2e57970089b9db83028fd984f0a79ddedab25dccfac3ba8c3e528c5f3133217d8d098faedcbb5c714002f51208
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # SidekiqScheduler
1
+ <p align="center">
2
+ <a href="http://moove-it.github.io/sidekiq-scheduler/">
3
+ <img src="https://moove-it.github.io/sidekiq-scheduler/images/logo.png" alt="Sidekiq Scheduler" />
4
+ </a>
5
+ </p>
2
6
 
3
7
  ## Note
4
8
 
@@ -22,7 +26,7 @@ details on individual methods, you might want to try the [rdoc](http://rdoc.info
22
26
 
23
27
  Add this to your Gemfile:
24
28
  ```ruby
25
- gem 'sidekiq-scheduler', '~> 1'
29
+ gem 'sidekiq-scheduler', '~> 1.2'
26
30
  ```
27
31
 
28
32
  If you are using rails you are set
@@ -62,7 +66,7 @@ is most likely stored in a YAML like so:
62
66
  queue_documents_for_indexing:
63
67
  cron: "0 0 * * *"
64
68
  # you can use rufus-scheduler "every" syntax in place of cron if you prefer
65
- # every: 1hr
69
+ # every: 1h
66
70
  # By default the job name (hash key) will be taken as worker class name.
67
71
  # If you want to have a different job name and class name, provide the 'class' option
68
72
  class: QueueDocuments
@@ -148,6 +152,17 @@ from the `config.time_zone` value, make sure it's the right format, e.g. with:
148
152
 
149
153
  A future version of sidekiq-scheduler may do this for you.
150
154
 
155
+ ### Sidekiq Web Integration
156
+
157
+ SidekiqScheduler provides an extension to the Sidekiq web interface that adds a Recurring Jobs page.
158
+
159
+ To use it, set up the Sidekiq web interface according to the Sidekiq documentation and then add the SidekiqScheduler::Web require:
160
+
161
+ ``` ruby
162
+ require 'sidekiq/web'
163
+ require 'sidekiq-scheduler/web'
164
+ ```
165
+
151
166
  ## Note on Patches / Pull Requests
152
167
 
153
168
  * Fork the project.
@@ -1,3 +1,5 @@
1
1
  module SidekiqScheduler
2
- VERSION = '1.1'
2
+
3
+ VERSION = '1.2'
4
+
3
5
  end
@@ -0,0 +1,19 @@
1
+ module SidekiqScheduler
2
+ # Hook into *Sidekiq::Web* Sinatra app which adds a new "/recurring-jobs" page
3
+
4
+ module Web
5
+ VIEW_PATH = File.expand_path('../../../web/views', __FILE__)
6
+
7
+ def self.registered(app)
8
+ app.get '/recurring-jobs' do
9
+ @schedule = Sidekiq.schedule
10
+
11
+ erb File.read(File.join(VIEW_PATH, "recurring_jobs.erb"))
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ require 'sidekiq/web' unless defined?(Sidekiq::Web)
18
+ Sidekiq::Web.register(SidekiqScheduler::Web)
19
+ Sidekiq::Web.tabs["Recurring Jobs"] = "recurring-jobs"
@@ -77,7 +77,7 @@ module Sidekiq
77
77
  if config['rails_env'].nil? || self.rails_env_matches?(config)
78
78
  logger.info "Scheduling #{name} "
79
79
  interval_defined = false
80
- interval_types = %w{cron every}
80
+ interval_types = %w{cron every at in}
81
81
  interval_types.each do |interval_type|
82
82
  if !config[interval_type].nil? && config[interval_type].length > 0
83
83
  args = self.optionizate_interval_value(config[interval_type])
@@ -160,6 +160,36 @@ class ManagerTest < Minitest::Test
160
160
  assert Sidekiq::Scheduler.scheduled_jobs['some_ivar_job'].params.keys.include?(:allow_overlapping)
161
161
  end
162
162
 
163
+ it 'load_schedule_job with at' do
164
+ Sidekiq::Scheduler.load_schedule_job(
165
+ 'some_ivar_job',
166
+ {
167
+ 'at' => "2013/12/12 12:30",
168
+ 'class' => 'SomeIvarJob',
169
+ 'args' => '/tmp'
170
+ }
171
+ )
172
+
173
+ assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
174
+ assert_equal(1, Sidekiq::Scheduler.scheduled_jobs.size)
175
+ assert Sidekiq::Scheduler.scheduled_jobs.keys.include?('some_ivar_job')
176
+ end
177
+
178
+ it 'load_schedule_job with in' do
179
+ Sidekiq::Scheduler.load_schedule_job(
180
+ 'some_ivar_job',
181
+ {
182
+ 'in' => "10d",
183
+ 'class' => 'SomeIvarJob',
184
+ 'args' => '/tmp'
185
+ }
186
+ )
187
+
188
+ assert_equal(1, Sidekiq::Scheduler.rufus_scheduler.all_jobs.size)
189
+ assert_equal(1, Sidekiq::Scheduler.scheduled_jobs.size)
190
+ assert Sidekiq::Scheduler.scheduled_jobs.keys.include?('some_ivar_job')
191
+ end
192
+
163
193
  it 'does not load the schedule without cron' do
164
194
  Sidekiq::Scheduler.load_schedule_job(
165
195
  'some_ivar_job',
@@ -240,4 +270,4 @@ class ManagerTest < Minitest::Test
240
270
  end
241
271
 
242
272
  end
243
- end
273
+ end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+ require 'sidekiq-scheduler/web'
3
+ require 'rack/test'
4
+
5
+ class WebTest < MiniTest::Test
6
+ describe 'sidekiq-scheduler web' do
7
+ include Rack::Test::Methods
8
+
9
+ def app
10
+ Sidekiq::Web
11
+ end
12
+
13
+ before do
14
+ # Sidekiq::WebHelpers expects the Redis client to return an id
15
+ Sidekiq.redis { |conn| conn.client.stubs(:id).returns('redis://127.0.0.1:1234/0') }
16
+
17
+ Sidekiq.schedule = {
18
+ 'Foo Job' => {
19
+ 'class' => 'FooClass',
20
+ 'cron' => '0 * * * * US/Eastern',
21
+ 'args' => [42],
22
+ 'description' => 'Does foo things.'
23
+ },
24
+
25
+ 'Bar Job' => {
26
+ 'class' => 'BarClass',
27
+ 'every' => '1h',
28
+ 'args' => ['foo', 'bar'],
29
+ 'queue' => 'special'
30
+ }
31
+ }
32
+ end
33
+
34
+ it 'shows schedule' do
35
+ get '/recurring-jobs'
36
+
37
+ assert_match /Foo Job/, last_response.body
38
+ assert_match /FooClass/, last_response.body
39
+ assert_match /0 \* \* \* \* US\/Eastern/, last_response.body
40
+ assert_match /default/, last_response.body
41
+ assert_match /\[42\]/, last_response.body
42
+ assert_match /Does foo things\./, last_response.body
43
+
44
+ assert_match /Bar Job/, last_response.body
45
+ assert_match /BarClass/, last_response.body
46
+ assert_match /1h/, last_response.body
47
+ assert_match /special/, last_response.body
48
+ assert_match /\[\"foo\", \"bar\"\]/, last_response.body
49
+ end
50
+ end
51
+ 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.1'
4
+ version: '1.2'
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-05-18 00:00:00.000000000 Z
12
+ date: 2015-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -157,6 +157,34 @@ dependencies:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: rack-test
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: sinatra
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
160
188
  description: Light weight job scheduling extension for Sidekiq that adds support for
161
189
  queueing items in the future.
162
190
  email:
@@ -173,11 +201,13 @@ files:
173
201
  - lib/sidekiq-scheduler/manager.rb
174
202
  - lib/sidekiq-scheduler/schedule.rb
175
203
  - lib/sidekiq-scheduler/version.rb
204
+ - lib/sidekiq-scheduler/web.rb
176
205
  - lib/sidekiq/scheduler.rb
177
206
  - lib/tasks/sidekiq-scheduler_tasks.rake
178
207
  - test/config.yml
179
208
  - test/fake_env.rb
180
209
  - test/lib/sidekiq/scheduler_test.rb
210
+ - test/lib/sidekiq/web_test.rb
181
211
  - test/schedule_test.rb
182
212
  - test/support/direct_worker.rb
183
213
  - test/support/my_worker.rb
@@ -202,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
232
  version: '0'
203
233
  requirements: []
204
234
  rubyforge_project:
205
- rubygems_version: 2.2.2
235
+ rubygems_version: 2.4.5
206
236
  signing_key:
207
237
  specification_version: 4
208
238
  summary: Light weight job scheduling extension for Sidekiq
@@ -210,6 +240,7 @@ test_files:
210
240
  - test/config.yml
211
241
  - test/fake_env.rb
212
242
  - test/lib/sidekiq/scheduler_test.rb
243
+ - test/lib/sidekiq/web_test.rb
213
244
  - test/schedule_test.rb
214
245
  - test/support/direct_worker.rb
215
246
  - test/support/my_worker.rb