qu-scheduler 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +2 -1
- data/README.md +191 -0
- data/lib/qu-scheduler.rb +1 -4
- data/lib/qu-scheduler/tasks.rb +35 -0
- data/lib/qu/extensions/scheduler.rb +102 -0
- data/lib/qu/extensions/scheduler/redis.rb +199 -0
- data/lib/qu/scheduler.rb +227 -0
- data/lib/qu/scheduler/version.rb +2 -2
- data/test/delayed_queue_test.rb +277 -0
- data/test/redis-test.conf +115 -0
- data/test/scheduler_args_test.rb +156 -0
- data/test/scheduler_hooks_test.rb +51 -0
- data/test/scheduler_test.rb +181 -0
- data/test/test_helper.rb +91 -7
- metadata +64 -76
- data/README.rdoc +0 -7
- data/lib/tasks/qu-scheduler_tasks.rake +0 -4
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -9
- data/test/dummy/app/assets/stylesheets/application.css +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -45
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -30
- data/test/dummy/config/environments/production.rb +0 -60
- data/test/dummy/config/environments/test.rb +0 -39
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -26
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,94 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
1
|
|
4
|
-
|
5
|
-
|
2
|
+
# Pretty much copied this file from the resque test_helper since we want
|
3
|
+
# to do all the same stuff
|
6
4
|
|
7
|
-
|
5
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
require 'rubygems'
|
8
|
+
require 'active_support'
|
9
|
+
require 'test/unit'
|
10
|
+
require 'mocha'
|
11
|
+
require 'qu-redis'
|
12
|
+
require File.join(dir, '../lib/qu-scheduler')
|
13
|
+
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__)) + '/../lib'
|
14
|
+
|
15
|
+
|
16
|
+
#
|
17
|
+
# make sure we can run redis
|
18
|
+
#
|
19
|
+
|
20
|
+
if !system("which redis-server")
|
21
|
+
puts '', "** can't find `redis-server` in your path"
|
22
|
+
puts "** try running `sudo rake install`"
|
23
|
+
abort ''
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
#
|
28
|
+
# start our own redis when the tests start,
|
29
|
+
# kill it when they end
|
30
|
+
#
|
31
|
+
|
32
|
+
at_exit do
|
33
|
+
next if $!
|
34
|
+
|
35
|
+
if defined?(MiniTest)
|
36
|
+
exit_code = MiniTest::Unit.new.run(ARGV)
|
37
|
+
else
|
38
|
+
exit_code = Test::Unit::AutoRunner.run
|
39
|
+
end
|
40
|
+
|
41
|
+
pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
|
42
|
+
puts "Killing test redis server..."
|
43
|
+
`rm -f #{dir}/dump.rdb`
|
44
|
+
Process.kill("KILL", pid.to_i)
|
45
|
+
exit exit_code
|
46
|
+
end
|
47
|
+
|
48
|
+
puts "Starting redis for testing at localhost:9736..."
|
49
|
+
`redis-server #{dir}/redis-test.conf`
|
50
|
+
Qu.configure do |c|
|
51
|
+
c.connection = Redis::Namespace.new('qu:scheduler', :redis => Redis.new(:host => 'localhost', :port => '9736'))
|
52
|
+
end
|
53
|
+
|
54
|
+
# Set logging threshold to unknown to suppress log output during tests
|
55
|
+
Qu.logger.level = Logger::UNKNOWN
|
56
|
+
|
57
|
+
##
|
58
|
+
# test/spec/mini 3
|
59
|
+
# http://gist.github.com/25455
|
60
|
+
# chris@ozmm.org
|
61
|
+
#
|
62
|
+
def context(*args, &block)
|
63
|
+
return super unless (name = args.first) && block
|
64
|
+
require 'test/unit'
|
65
|
+
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
|
66
|
+
def self.test(name, &block)
|
67
|
+
define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
|
68
|
+
end
|
69
|
+
def self.xtest(*args) end
|
70
|
+
def self.setup(&block) define_method(:setup, &block) end
|
71
|
+
def self.teardown(&block) define_method(:teardown, &block) end
|
72
|
+
end
|
73
|
+
(class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
|
74
|
+
klass.class_eval &block
|
75
|
+
end
|
76
|
+
|
77
|
+
class FakeCustomJobClass
|
78
|
+
def self.scheduled(queue, klass, *args); end
|
79
|
+
end
|
80
|
+
|
81
|
+
class SomeJob
|
82
|
+
def self.perform(repo_id, path)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class SomeIvarJob < SomeJob
|
87
|
+
@queue = :ivar
|
88
|
+
end
|
89
|
+
|
90
|
+
class SomeRealClass
|
91
|
+
def self.queue
|
92
|
+
:some_real_queue
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qu-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: qu-redis
|
16
|
+
requirement: &70248981633420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.1.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70248981633420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: rufus-scheduler
|
27
|
+
requirement: &70248981632880 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70248981632880
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70248981632440 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,10 +43,32 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70248981632440
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
48
|
+
name: rack-test
|
49
|
+
requirement: &70248981631940 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70248981631940
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: turn
|
60
|
+
requirement: &70248981631460 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70248981631460
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: &70248981630940 !ruby/object:Gem::Requirement
|
39
72
|
none: false
|
40
73
|
requirements:
|
41
74
|
- - ! '>='
|
@@ -43,7 +76,7 @@ dependencies:
|
|
43
76
|
version: '0'
|
44
77
|
type: :development
|
45
78
|
prerelease: false
|
46
|
-
version_requirements: *
|
79
|
+
version_requirements: *70248981630940
|
47
80
|
description: Qu::Scheduler is an extension to Qu that adds support for queueing items
|
48
81
|
in the future.
|
49
82
|
email:
|
@@ -52,42 +85,21 @@ executables: []
|
|
52
85
|
extensions: []
|
53
86
|
extra_rdoc_files: []
|
54
87
|
files:
|
88
|
+
- lib/qu/extensions/scheduler/redis.rb
|
89
|
+
- lib/qu/extensions/scheduler.rb
|
55
90
|
- lib/qu/scheduler/version.rb
|
91
|
+
- lib/qu/scheduler.rb
|
92
|
+
- lib/qu-scheduler/tasks.rb
|
56
93
|
- lib/qu-scheduler.rb
|
57
|
-
- lib/tasks/qu-scheduler_tasks.rake
|
58
94
|
- MIT-LICENSE
|
59
95
|
- Rakefile
|
60
|
-
- README.
|
61
|
-
- test/
|
62
|
-
- test/dummy/app/assets/stylesheets/application.css
|
63
|
-
- test/dummy/app/controllers/application_controller.rb
|
64
|
-
- test/dummy/app/helpers/application_helper.rb
|
65
|
-
- test/dummy/app/views/layouts/application.html.erb
|
66
|
-
- test/dummy/config/application.rb
|
67
|
-
- test/dummy/config/boot.rb
|
68
|
-
- test/dummy/config/database.yml
|
69
|
-
- test/dummy/config/environment.rb
|
70
|
-
- test/dummy/config/environments/development.rb
|
71
|
-
- test/dummy/config/environments/production.rb
|
72
|
-
- test/dummy/config/environments/test.rb
|
73
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
74
|
-
- test/dummy/config/initializers/inflections.rb
|
75
|
-
- test/dummy/config/initializers/mime_types.rb
|
76
|
-
- test/dummy/config/initializers/secret_token.rb
|
77
|
-
- test/dummy/config/initializers/session_store.rb
|
78
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
79
|
-
- test/dummy/config/locales/en.yml
|
80
|
-
- test/dummy/config/routes.rb
|
81
|
-
- test/dummy/config.ru
|
82
|
-
- test/dummy/db/test.sqlite3
|
83
|
-
- test/dummy/log/test.log
|
84
|
-
- test/dummy/public/404.html
|
85
|
-
- test/dummy/public/422.html
|
86
|
-
- test/dummy/public/500.html
|
87
|
-
- test/dummy/public/favicon.ico
|
88
|
-
- test/dummy/Rakefile
|
89
|
-
- test/dummy/script/rails
|
96
|
+
- README.md
|
97
|
+
- test/delayed_queue_test.rb
|
90
98
|
- test/qu-scheduler_test.rb
|
99
|
+
- test/redis-test.conf
|
100
|
+
- test/scheduler_args_test.rb
|
101
|
+
- test/scheduler_hooks_test.rb
|
102
|
+
- test/scheduler_test.rb
|
91
103
|
- test/test_helper.rb
|
92
104
|
homepage: https://github.com/yabawock/qu-scheduler
|
93
105
|
licenses: []
|
@@ -103,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
115
|
version: '0'
|
104
116
|
segments:
|
105
117
|
- 0
|
106
|
-
hash:
|
118
|
+
hash: 738581818219182694
|
107
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
120
|
none: false
|
109
121
|
requirements:
|
@@ -112,42 +124,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
124
|
version: '0'
|
113
125
|
segments:
|
114
126
|
- 0
|
115
|
-
hash:
|
127
|
+
hash: 738581818219182694
|
116
128
|
requirements: []
|
117
129
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.8.
|
130
|
+
rubygems_version: 1.8.6
|
119
131
|
signing_key:
|
120
132
|
specification_version: 3
|
121
133
|
summary: A light-weight job scheduling system built on top of Qu.
|
122
134
|
test_files:
|
123
|
-
- test/
|
124
|
-
- test/dummy/app/assets/stylesheets/application.css
|
125
|
-
- test/dummy/app/controllers/application_controller.rb
|
126
|
-
- test/dummy/app/helpers/application_helper.rb
|
127
|
-
- test/dummy/app/views/layouts/application.html.erb
|
128
|
-
- test/dummy/config/application.rb
|
129
|
-
- test/dummy/config/boot.rb
|
130
|
-
- test/dummy/config/database.yml
|
131
|
-
- test/dummy/config/environment.rb
|
132
|
-
- test/dummy/config/environments/development.rb
|
133
|
-
- test/dummy/config/environments/production.rb
|
134
|
-
- test/dummy/config/environments/test.rb
|
135
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
136
|
-
- test/dummy/config/initializers/inflections.rb
|
137
|
-
- test/dummy/config/initializers/mime_types.rb
|
138
|
-
- test/dummy/config/initializers/secret_token.rb
|
139
|
-
- test/dummy/config/initializers/session_store.rb
|
140
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
141
|
-
- test/dummy/config/locales/en.yml
|
142
|
-
- test/dummy/config/routes.rb
|
143
|
-
- test/dummy/config.ru
|
144
|
-
- test/dummy/db/test.sqlite3
|
145
|
-
- test/dummy/log/test.log
|
146
|
-
- test/dummy/public/404.html
|
147
|
-
- test/dummy/public/422.html
|
148
|
-
- test/dummy/public/500.html
|
149
|
-
- test/dummy/public/favicon.ico
|
150
|
-
- test/dummy/Rakefile
|
151
|
-
- test/dummy/script/rails
|
135
|
+
- test/delayed_queue_test.rb
|
152
136
|
- test/qu-scheduler_test.rb
|
137
|
+
- test/redis-test.conf
|
138
|
+
- test/scheduler_args_test.rb
|
139
|
+
- test/scheduler_hooks_test.rb
|
140
|
+
- test/scheduler_test.rb
|
153
141
|
- test/test_helper.rb
|
data/README.rdoc
DELETED
data/test/dummy/Rakefile
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
-
|
5
|
-
require File.expand_path('../config/application', __FILE__)
|
6
|
-
|
7
|
-
Dummy::Application.load_tasks
|
@@ -1,9 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
-
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
-
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
-
// the compiled file.
|
6
|
-
//
|
7
|
-
//= require jquery
|
8
|
-
//= require jquery_ujs
|
9
|
-
//= require_tree .
|
@@ -1,7 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
-
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
-
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
-
*= require_self
|
6
|
-
*= require_tree .
|
7
|
-
*/
|
data/test/dummy/config.ru
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
Bundler.require
|
6
|
-
require "qu-scheduler"
|
7
|
-
|
8
|
-
module Dummy
|
9
|
-
class Application < Rails::Application
|
10
|
-
# Settings in config/environments/* take precedence over those specified here.
|
11
|
-
# Application configuration should go into files in config/initializers
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
-
|
17
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
-
|
21
|
-
# Activate observers that should always be running.
|
22
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
-
|
24
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
-
|
28
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
-
# config.i18n.default_locale = :de
|
31
|
-
|
32
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
-
config.encoding = "utf-8"
|
34
|
-
|
35
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
-
config.filter_parameters += [:password]
|
37
|
-
|
38
|
-
# Enable the asset pipeline
|
39
|
-
config.assets.enabled = true
|
40
|
-
|
41
|
-
# Version of your assets, change this if you want to expire all your assets
|
42
|
-
config.assets.version = '1.0'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
data/test/dummy/config/boot.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
development:
|
7
|
-
adapter: sqlite3
|
8
|
-
database: db/development.sqlite3
|
9
|
-
pool: 5
|
10
|
-
timeout: 5000
|
11
|
-
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
|
-
test:
|
16
|
-
adapter: sqlite3
|
17
|
-
database: db/test.sqlite3
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
20
|
-
|
21
|
-
production:
|
22
|
-
adapter: sqlite3
|
23
|
-
database: db/production.sqlite3
|
24
|
-
pool: 5
|
25
|
-
timeout: 5000
|