resque-scheduler 2.5.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of resque-scheduler might be problematic. Click here for more details.

Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -6
  3. data/.rubocop.yml +18 -113
  4. data/.rubocop_todo.yml +29 -0
  5. data/.simplecov +3 -1
  6. data/.travis.yml +12 -4
  7. data/.vagrant-provision-as-vagrant.sh +15 -0
  8. data/.vagrant-provision.sh +23 -0
  9. data/.vagrant-skel/bash_profile +7 -0
  10. data/.vagrant-skel/bashrc +7 -0
  11. data/AUTHORS.md +5 -0
  12. data/Gemfile +1 -2
  13. data/HISTORY.md +18 -0
  14. data/README.md +39 -11
  15. data/ROADMAP.md +0 -6
  16. data/Rakefile +11 -19
  17. data/Vagrantfile +14 -0
  18. data/bin/resque-scheduler +2 -2
  19. data/examples/Rakefile +1 -1
  20. data/examples/config/initializers/resque-web.rb +2 -2
  21. data/examples/dynamic-scheduling/app/jobs/fix_schedules_job.rb +2 -4
  22. data/examples/dynamic-scheduling/app/jobs/send_email_job.rb +1 -1
  23. data/examples/dynamic-scheduling/app/models/user.rb +2 -2
  24. data/examples/dynamic-scheduling/lib/tasks/resque.rake +2 -2
  25. data/lib/resque-scheduler.rb +3 -1
  26. data/lib/resque/scheduler.rb +112 -168
  27. data/lib/resque/scheduler/cli.rb +144 -0
  28. data/lib/resque/scheduler/configuration.rb +73 -0
  29. data/lib/resque/scheduler/delaying_extensions.rb +278 -0
  30. data/lib/resque/scheduler/env.rb +61 -0
  31. data/lib/resque/scheduler/extension.rb +13 -0
  32. data/lib/resque/scheduler/lock.rb +2 -1
  33. data/lib/resque/scheduler/lock/base.rb +6 -2
  34. data/lib/resque/scheduler/lock/basic.rb +4 -5
  35. data/lib/resque/scheduler/lock/resilient.rb +30 -37
  36. data/lib/resque/scheduler/locking.rb +94 -0
  37. data/lib/resque/scheduler/logger_builder.rb +72 -0
  38. data/lib/resque/scheduler/plugin.rb +31 -0
  39. data/lib/resque/scheduler/scheduling_extensions.rb +150 -0
  40. data/lib/resque/scheduler/server.rb +246 -0
  41. data/lib/{resque_scheduler → resque/scheduler}/server/views/delayed.erb +2 -1
  42. data/lib/{resque_scheduler → resque/scheduler}/server/views/delayed_schedules.erb +0 -0
  43. data/lib/{resque_scheduler → resque/scheduler}/server/views/delayed_timestamp.erb +0 -0
  44. data/lib/{resque_scheduler → resque/scheduler}/server/views/requeue-params.erb +0 -0
  45. data/lib/{resque_scheduler → resque/scheduler}/server/views/scheduler.erb +16 -1
  46. data/lib/{resque_scheduler → resque/scheduler}/server/views/search.erb +2 -1
  47. data/lib/{resque_scheduler → resque/scheduler}/server/views/search_form.erb +0 -0
  48. data/lib/resque/scheduler/signal_handling.rb +40 -0
  49. data/lib/{resque_scheduler → resque/scheduler}/tasks.rb +3 -5
  50. data/lib/resque/scheduler/util.rb +41 -0
  51. data/lib/resque/scheduler/version.rb +7 -0
  52. data/resque-scheduler.gemspec +21 -19
  53. data/script/migrate_to_timestamps_set.rb +5 -3
  54. data/tasks/resque_scheduler.rake +1 -1
  55. data/test/cli_test.rb +26 -69
  56. data/test/delayed_queue_test.rb +262 -169
  57. data/test/env_test.rb +41 -0
  58. data/test/resque-web_test.rb +169 -48
  59. data/test/scheduler_args_test.rb +73 -41
  60. data/test/scheduler_hooks_test.rb +9 -8
  61. data/test/scheduler_locking_test.rb +55 -36
  62. data/test/scheduler_setup_test.rb +52 -15
  63. data/test/scheduler_task_test.rb +15 -10
  64. data/test/scheduler_test.rb +215 -114
  65. data/test/support/redis_instance.rb +32 -33
  66. data/test/test_helper.rb +33 -36
  67. data/test/util_test.rb +11 -0
  68. metadata +113 -57
  69. data/lib/resque/scheduler_locking.rb +0 -91
  70. data/lib/resque_scheduler.rb +0 -386
  71. data/lib/resque_scheduler/cli.rb +0 -160
  72. data/lib/resque_scheduler/logger_builder.rb +0 -72
  73. data/lib/resque_scheduler/plugin.rb +0 -28
  74. data/lib/resque_scheduler/server.rb +0 -183
  75. data/lib/resque_scheduler/util.rb +0 -34
  76. data/lib/resque_scheduler/version.rb +0 -5
  77. data/test/redis-test.conf +0 -108
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62efe393e6b613cf1d08a9d757105c124976010d
4
- data.tar.gz: 9e61be4df36fa45b2e46ce09b97d8460481bf814
3
+ metadata.gz: 315b0ea47908358f5cd357a315f9bcf958402ccb
4
+ data.tar.gz: 8bcbe775f3fc7f68d47a7d0cf79f75b2f27ac0b3
5
5
  SHA512:
6
- metadata.gz: 031282aff18c1d4ed4b57b906190adcae00c303cfa50ef66cbe6823761da44180194e64f15d5e81474486092e71a86d24d258294092dc00b2da5f2a27bd26024
7
- data.tar.gz: 310937e91fd414c72d95f5394e9dd38090a6e291ba94b78cbab470e5ca9dd92c8365853c0244460e0934cafbac43835fe97adcc0c6de63d4c3eecee5737dac48
6
+ metadata.gz: 40b428d2bfdbd36eb3ba623812a3d06db24a674531db24069c9dd19e24af478c49eafe615238d333ae9181ecf2ca3e76a0a8f9b20f2181431a4ff147733d80f4
7
+ data.tar.gz: ce2e9aee9671c7a4ffbf016934d169ee36d575543142fccea9318244c8a84c20108878ed5010ace31d67aa706bc6f4793aabc5952bf521aeecf0f33728ac18f4
data/.gitignore CHANGED
@@ -1,11 +1,17 @@
1
- .bundle/
2
- .idea/
1
+ /.bundle/
2
+ /.idea/
3
+ /.yardoc/
3
4
 
4
- doc/
5
- pkg
5
+ /doc/
6
+ /pkg/
6
7
  nbproject
7
- Gemfile.lock
8
- .rvmrc
8
+ /Gemfile.lock
9
+ /.rvmrc
9
10
  *.swp
10
11
 
11
12
  /coverage/
13
+ /.vagrant/
14
+ /dump.rdb
15
+
16
+ .env
17
+ .env.*
@@ -1,129 +1,34 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`.
2
- # The point is for the user to remove these configuration records
3
- # one by one as the offences are removed from the code base.
1
+ inherit_from: .rubocop_todo.yml
4
2
 
5
- AccessorMethodName:
6
- Enabled: false
7
-
8
- AlignParameters:
9
- Enabled: false
10
-
11
- AssignmentInCondition:
12
- Enabled: false
13
-
14
- BracesAroundHashParameters:
15
- Enabled: false
3
+ AllCops:
4
+ Include:
5
+ - Gemfile
6
+ - '**/Rakefile'
7
+ - resque-scheduler.gemspec
8
+ - bin/resque-scheduler
16
9
 
10
+ # Offence count: 1
17
11
  CaseEquality:
18
12
  Enabled: false
19
13
 
14
+ # Offence count: 2
15
+ # Configuration parameters: CountComments.
20
16
  ClassLength:
21
- Max: 325
22
-
23
- ClassVars:
24
- Enabled: false
25
-
26
- CollectionMethods:
27
- Enabled: false
28
-
29
- ColonMethodCall:
30
- Enabled: false
31
-
32
- CommentAnnotation:
33
- Enabled: false
17
+ Max: 130
34
18
 
19
+ # Offence count: 3
35
20
  CyclomaticComplexity:
36
- Max: 28
21
+ Max: 21
37
22
 
23
+ # Offence count: 29
38
24
  Documentation:
39
25
  Enabled: false
40
26
 
41
- Encoding:
42
- Enabled: false
43
-
44
- FavorUnlessOverNegatedIf:
45
- Enabled: false
46
-
47
- FavorUntilOverNegatedWhile:
48
- Enabled: false
49
-
50
- HandleExceptions:
51
- Enabled: false
52
-
53
- HashSyntax:
54
- Enabled: false
55
-
56
- IfUnlessModifier:
57
- Enabled: false
58
-
59
- IndentationWidth:
60
- Enabled: false
61
-
62
- LineLength:
63
- Max: 152
64
-
65
- Loop:
66
- Enabled: false
67
-
68
- MethodCallParentheses:
69
- Enabled: false
70
-
27
+ # Offence count: 17
28
+ # Configuration parameters: CountComments.
71
29
  MethodLength:
72
- Max: 180
73
-
74
- ModuleFunction:
75
- Enabled: false
76
-
77
- NumericLiterals:
78
- Enabled: false
79
-
80
- ParenthesesAroundCondition:
81
- Enabled: false
82
-
83
- PredicateName:
84
- Enabled: false
85
-
86
- RedundantBegin:
87
- Enabled: false
30
+ Max: 145
88
31
 
32
+ # Offence count: 1
89
33
  RescueException:
90
34
  Enabled: false
91
-
92
- RescueModifier:
93
- Enabled: false
94
-
95
- SingleLineMethods:
96
- Enabled: false
97
-
98
- SpaceAfterComma:
99
- Enabled: false
100
-
101
- SpaceAroundBlockBraces:
102
- Enabled: false
103
-
104
- SpaceAroundEqualsInParameterDefault:
105
- Enabled: false
106
-
107
- SpaceAroundOperators:
108
- Enabled: false
109
-
110
- SpaceInsideHashLiteralBraces:
111
- Enabled: false
112
-
113
- SpecialGlobalVars:
114
- Enabled: false
115
-
116
- StringLiterals:
117
- Enabled: false
118
-
119
- TrailingBlankLines:
120
- Enabled: false
121
-
122
- TrailingWhitespace:
123
- Enabled: false
124
-
125
- TrivialAccessors:
126
- Enabled: false
127
-
128
- UselessAssignment:
129
- Enabled: false
@@ -0,0 +1,29 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-05-24 08:24:15 -0400 using RuboCop version 0.22.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 12
9
+ DoubleNegation:
10
+ Enabled: false
11
+
12
+ # Offense count: 1
13
+ EachWithObject:
14
+ Enabled: false
15
+
16
+ # Offense count: 3
17
+ # Configuration parameters: Exclude.
18
+ FileName:
19
+ Enabled: false
20
+
21
+ # Offense count: 7
22
+ # Configuration parameters: MinBodyLength.
23
+ GuardClause:
24
+ Enabled: false
25
+
26
+ # Offense count: 1
27
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
28
+ Next:
29
+ Enabled: false
data/.simplecov CHANGED
@@ -1 +1,3 @@
1
- SimpleCov.start { add_filter '/test/' } if ENV['COVERAGE']
1
+ if ENV['COVERAGE'] && RUBY_PLATFORM !~ /java/
2
+ SimpleCov.start { add_filter '/test/' }
3
+ end
@@ -1,15 +1,23 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
3
+ - '1.9.3'
4
+ - '2.1'
5
+ - 'jruby-19mode'
6
+ - 'rbx'
5
7
  env:
6
8
  global:
7
9
  - RESQUE_SCHEDULER_DISABLE_TEST_REDIS_SERVER=1
10
+ - JRUBY_OPTS='-Xcext.enabled=true'
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: 'jruby-19mode'
14
+ - rvm: 'rbx'
8
15
  services:
9
16
  - redis-server
10
17
  notifications:
11
18
  email:
12
- recipients: daniel.buch+resque-scheduler@gmail.com
19
+ recipients:
20
+ - daniel.buch+resque-scheduler@gmail.com
13
21
  deploy:
14
22
  provider: rubygems
15
23
  api_key:
@@ -18,4 +26,4 @@ deploy:
18
26
  on:
19
27
  tags: true
20
28
  repo: resque/resque-scheduler
21
- rvm: 2.0.0
29
+ rvm: '2.1'
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+ set -x
5
+
6
+ ln -svf /vagrant/.vagrant-skel/bashrc ~/.bashrc
7
+ ln -svf /vagrant/.vagrant-skel/bash_profile ~/.bash_profile
8
+
9
+ source ~/.bashrc
10
+
11
+ set +x
12
+ curl -L https://get.rvm.io | bash -s stable --ruby=2.0.0 --auto-dotfiles
13
+
14
+ source ~/.rvm/scripts/rvm
15
+ gem install --no-ri --no-rdoc bundler foreman
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ export DEBIAN_FRONTEND=noninteractive
4
+
5
+ umask 022
6
+
7
+ set -e
8
+ set -x
9
+
10
+ apt-get update -yq
11
+ apt-get install --no-install-suggests -yq python-software-properties
12
+ add-apt-repository -y ppa:chris-lea/redis-server
13
+ apt-get update -yq
14
+ apt-get install --no-install-suggests -yq \
15
+ build-essential \
16
+ byobu \
17
+ curl \
18
+ git \
19
+ make \
20
+ redis-server \
21
+ screen
22
+
23
+ su - vagrant -c /vagrant/.vagrant-provision-as-vagrant.sh
@@ -0,0 +1,7 @@
1
+ #!bash
2
+
3
+ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
4
+
5
+ if [[ "$PS1" ]] ; then
6
+ cd /vagrant
7
+ fi
@@ -0,0 +1,7 @@
1
+ #!bash
2
+
3
+ export LANG='en_US.UTF-8'
4
+ export LANGUAGE='en_US.UTF-8'
5
+ export LC_ALL='en_US.UTF-8'
6
+
7
+ export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
data/AUTHORS.md CHANGED
@@ -3,6 +3,7 @@ Resque Scheduler authors
3
3
 
4
4
  - Aaron Suggs
5
5
  - Alexander Simonov
6
+ - Andrea Campolonghi
6
7
  - Ben VandenBos
7
8
  - Bernerd Schaefer
8
9
  - Bogdan Gusiev
@@ -29,6 +30,7 @@ Resque Scheduler authors
29
30
  - John Crepezzi
30
31
  - John Griffin
31
32
  - Jon Larkowski and Les Hill
33
+ - Jonathan Conley
32
34
  - Jonathan Hyman
33
35
  - Jonathan Owens
34
36
  - Joshua Szmajda
@@ -57,9 +59,12 @@ Resque Scheduler authors
57
59
  - Tim Liner
58
60
  - Tony Lewis
59
61
  - Vincent Zhu
62
+ - Vladislav Shub
60
63
  - V Sreekanth
64
+ - Warren Sangster
61
65
  - andreas
62
66
  - bbauer
67
+ - camol
63
68
  - fallwith
64
69
  - gravis
65
70
  - hpoydar
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
+ # vim:fileencoding=utf-8
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gemspec
4
-
5
- gem 'yajl-ruby', '>= 1.1.0', :platforms => :mri, :group => :test
data/HISTORY.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Resque Scheduler History / ChangeLog / Release Notes
2
2
 
3
+ ## 3.0.0 (2014-05-27)
4
+ * The grand re-namespacing of
5
+ `resque_scheduler/(.*)` => `resque/scheduler/\1`
6
+ * Cleanup of a ton of rubocop offenses
7
+ * Vagrant setup
8
+ * Documentation updates
9
+ * "Refactoring"
10
+ * Added support for last execution information through the web
11
+ * Handling signals while "sleeping" by relying on `Thread#wakeup`
12
+ * CodeClimate integration
13
+ * Addition of `Resque.delayed?` and `Resque.next_delayed_schedule`
14
+ * Testing against same rubies as resque (+ 2.1.1)
15
+ * Renamed `Resque.set_last_run` to `Resque.last_enqueued_at`
16
+ * Allow scheduled jobs to be deleted via resque web
17
+ * Fixed duplicated layout for `search_form` partial template.
18
+ * Fix issue where Web UI was ONLY showing jobs that only run in the current
19
+ environment
20
+
3
21
  ## 2.5.5 (2014-02-27)
4
22
  * Only showing link to job with args if job is present
5
23
  * Only showing scheduled jobs that match current env or omit env
data/README.md CHANGED
@@ -4,6 +4,7 @@ resque-scheduler
4
4
  [![Dependency Status](https://gemnasium.com/resque/resque-scheduler.png)](https://gemnasium.com/resque/resque-scheduler)
5
5
  [![Gem Version](https://badge.fury.io/rb/resque-scheduler.png)](http://badge.fury.io/rb/resque-scheduler)
6
6
  [![Build Status](https://travis-ci.org/resque/resque-scheduler.png?branch=master)](https://travis-ci.org/resque/resque-scheduler)
7
+ [![Code Climate](https://codeclimate.com/github/resque/resque-scheduler.png)](https://codeclimate.com/github/resque/resque-scheduler)
7
8
 
8
9
  ### Description
9
10
 
@@ -52,7 +53,7 @@ gem 'resque-scheduler'
52
53
  Adding the resque:scheduler rake task:
53
54
 
54
55
  ```ruby
55
- require 'resque_scheduler/tasks'
56
+ require 'resque/scheduler/tasks'
56
57
  ```
57
58
 
58
59
  ### Rake integration
@@ -65,12 +66,12 @@ everything `resque` needs to know.
65
66
  ```ruby
66
67
  # Resque tasks
67
68
  require 'resque/tasks'
68
- require 'resque_scheduler/tasks'
69
+ require 'resque/scheduler/tasks'
69
70
 
70
71
  namespace :resque do
71
72
  task :setup do
72
73
  require 'resque'
73
- require 'resque_scheduler'
74
+ require 'resque-scheduler'
74
75
 
75
76
  # you probably already have this somewhere
76
77
  Resque.redis = 'localhost:6379'
@@ -144,8 +145,8 @@ scheduled job must run (coerced with `Kernel#Float()`) (default `5`)
144
145
  * `LOGFORMAT` - Log output format to use (either `'text'` or `'json'`,
145
146
  default `'text'`)
146
147
  * `PIDFILE` - If non-empty, write process PID to file (default empty)
147
- * `QUIET` or `MUTE` - Silence most output if non-empty (equivalent to
148
- a level of `MonoLogger::FATAL`, default `false`)
148
+ * `QUIET` - Silence most output if non-empty (equivalent to a level of
149
+ `MonoLogger::FATAL`, default `false`)
149
150
  * `VERBOSE` - Maximize log verbosity if non-empty (equivalent to a level
150
151
  of `MonoLogger::DEBUG`, default `false`)
151
152
 
@@ -447,7 +448,7 @@ redis instance and schedule. The scheduler processes will use redis to
447
448
  elect a master process and detect failover when the master dies. Precautions are
448
449
  taken to prevent jobs from potentially being queued twice during failover even
449
450
  when the clocks of the scheduler machines are slightly out of sync (or load affects
450
- scheduled job firing time). If you want the gory details, look at Resque::SchedulerLocking.
451
+ scheduled job firing time). If you want the gory details, look at Resque::Scheduler::Locking.
451
452
 
452
453
  If the scheduler process(es) goes down for whatever reason, the delayed items
453
454
  that should have fired during the outage will fire once the scheduler process
@@ -494,8 +495,8 @@ Now, you want to add the following:
494
495
 
495
496
  ```ruby
496
497
  # This will make the tabs show up.
497
- require 'resque_scheduler'
498
- require 'resque_scheduler/server'
498
+ require 'resque-scheduler'
499
+ require 'resque/scheduler/server'
499
500
  ```
500
501
 
501
502
  That should make the scheduler tabs show up in `resque-web`.
@@ -533,8 +534,8 @@ worker is started.
533
534
  There are several options to toggle the way scheduler logs its actions. They
534
535
  are toggled by environment variables:
535
536
 
536
- - `MUTE` will stop logging anything. Completely silent.
537
- - `VERBOSE` opposite of 'mute'; will log even debug information
537
+ - `QUIET` will stop logging anything. Completely silent.
538
+ - `VERBOSE` opposite of 'QUIET'; will log even debug information
538
539
  - `LOGFILE` specifies the file to write logs to. (default standard output)
539
540
  - `LOGFORMAT` specifies either "text" or "json" output format
540
541
  (default "text")
@@ -544,7 +545,7 @@ values:
544
545
 
545
546
  ```ruby
546
547
  Resque::Scheduler.configure do |c|
547
- c.mute = false
548
+ c.quiet = false
548
549
  c.verbose = false
549
550
  c.logfile = nil # meaning all messages go to $stdout
550
551
  c.logformat = 'text'
@@ -570,6 +571,33 @@ of the code looking very similar to resque, particularly in resque-web
570
571
  and the views. I wanted it to be similar enough that someone familiar
571
572
  with resque could easily work on resque-scheduler.
572
573
 
574
+ ### Development
575
+
576
+ Working on resque-scheduler requires the following:
577
+
578
+ * A relatively modern Ruby interpreter (MRI 1.9+ is what's tested)
579
+ * bundler
580
+
581
+ The development setup looks like this, which is roughly the same thing
582
+ that happens on Travis CI:
583
+
584
+ ``` bash
585
+ # Install everything
586
+ bundle install
587
+
588
+ # Make sure tests are green before you change stuff
589
+ bundle exec rake
590
+ # Change stuff
591
+ # Repeat
592
+ ```
593
+
594
+ If you have [vagrant](http://www.vagrantup.com) installed, there is a
595
+ development box available that requires no plugins or external
596
+ provisioners:
597
+
598
+ ``` bash
599
+ vagrant up
600
+ ```
573
601
 
574
602
  ### Contributing
575
603