qu 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -3
- data/README.md +2 -1
- data/Rakefile +1 -1
- data/lib/qu.rb +14 -3
- data/lib/qu/backend/base.rb +1 -0
- data/lib/qu/backend/spec.rb +65 -56
- data/lib/qu/logger.rb +20 -0
- data/lib/qu/{job.rb → payload.rb} +21 -5
- data/lib/qu/railtie.rb +4 -0
- data/lib/qu/tasks.rb +7 -0
- data/lib/qu/version.rb +1 -1
- data/lib/qu/worker.rb +16 -2
- data/qu.gemspec +1 -1
- data/spec/qu/{job_spec.rb → payload_spec.rb} +17 -9
- data/spec/qu/worker_spec.rb +1 -1
- data/spec/qu_spec.rb +13 -1
- data/spec/spec_helper.rb +3 -1
- metadata +35 -57
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
|
|
2
2
|
gemspec :name => 'qu'
|
3
3
|
|
4
4
|
Dir['qu-*.gemspec'].each do |gemspec|
|
5
|
-
plugin = gemspec.scan(/qu-(.*)\.gemspec/).
|
5
|
+
plugin = gemspec.scan(/qu-(.*)\.gemspec/).flatten.first
|
6
6
|
|
7
7
|
group plugin do
|
8
8
|
gemspec(:name => "qu-#{plugin}", :development_group => plugin)
|
@@ -10,8 +10,9 @@ Dir['qu-*.gemspec'].each do |gemspec|
|
|
10
10
|
end
|
11
11
|
|
12
12
|
group :test do
|
13
|
-
gem 'SystemTimer',
|
14
|
-
gem 'ruby-debug',
|
13
|
+
gem 'SystemTimer', :platform => :mri_18
|
14
|
+
gem 'ruby-debug', :platform => :mri_18
|
15
|
+
gem 'ruby-debug19', :platform => :mri_19, :require => 'ruby-debug'
|
15
16
|
gem 'rake'
|
16
17
|
gem 'rspec', '~> 2.0'
|
17
18
|
gem 'guard-rspec'
|
data/README.md
CHANGED
@@ -102,7 +102,8 @@ However, if you do need to customize it, you can by calling the `Qu.configure`:
|
|
102
102
|
|
103
103
|
``` ruby
|
104
104
|
Qu.configure do |c|
|
105
|
-
c.connection
|
105
|
+
c.connection = Redis::Namespace.new('myapp:qu', :redis => Redis.connect)
|
106
|
+
c.logger = Logger.new('log/qu.log')
|
106
107
|
end
|
107
108
|
```
|
108
109
|
|
data/Rakefile
CHANGED
data/lib/qu.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'qu/version'
|
2
|
+
require 'qu/logger'
|
2
3
|
require 'qu/failure'
|
3
|
-
require 'qu/
|
4
|
+
require 'qu/payload'
|
4
5
|
require 'qu/backend/base'
|
5
6
|
|
6
7
|
require 'forwardable'
|
8
|
+
require 'logger'
|
7
9
|
|
8
10
|
module Qu
|
9
11
|
autoload :Worker, 'qu/worker'
|
@@ -11,9 +13,9 @@ module Qu
|
|
11
13
|
extend SingleForwardable
|
12
14
|
extend self
|
13
15
|
|
14
|
-
attr_accessor :backend, :failure
|
16
|
+
attr_accessor :backend, :failure, :logger
|
15
17
|
|
16
|
-
def_delegators :backend, :
|
18
|
+
def_delegators :backend, :length, :queues, :reserve, :clear, :connection=
|
17
19
|
|
18
20
|
def backend
|
19
21
|
@backend || raise("Qu backend not configured. Install one of the backend gems like qu-redis.")
|
@@ -22,6 +24,15 @@ module Qu
|
|
22
24
|
def configure(&block)
|
23
25
|
block.call(self)
|
24
26
|
end
|
27
|
+
|
28
|
+
def enqueue(klass, *args)
|
29
|
+
backend.enqueue Payload.new(:klass => klass, :args => args)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Qu.configure do |c|
|
34
|
+
c.logger = Logger.new(STDOUT)
|
35
|
+
c.logger.level = Logger::INFO
|
25
36
|
end
|
26
37
|
|
27
38
|
require 'qu/railtie' if defined?(Rails)
|
data/lib/qu/backend/base.rb
CHANGED
data/lib/qu/backend/spec.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
unless defined?(SystemTimer)
|
2
|
+
require 'timeout'
|
3
|
+
SystemTimer = Timeout
|
4
|
+
end
|
5
|
+
|
1
6
|
class SimpleJob
|
2
7
|
def self.perform
|
3
8
|
end
|
@@ -9,6 +14,7 @@ end
|
|
9
14
|
|
10
15
|
shared_examples_for 'a backend' do
|
11
16
|
let(:worker) { Qu::Worker.new('default') }
|
17
|
+
let(:payload) { Qu::Payload.new(:klass => SimpleJob) }
|
12
18
|
|
13
19
|
before(:all) do
|
14
20
|
Qu.backend = described_class.new
|
@@ -20,53 +26,58 @@ shared_examples_for 'a backend' do
|
|
20
26
|
end
|
21
27
|
|
22
28
|
describe 'enqueue' do
|
23
|
-
it 'should return a
|
24
|
-
subject.enqueue(
|
29
|
+
it 'should return a payload' do
|
30
|
+
subject.enqueue(payload).should be_instance_of(Qu::Payload)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should set the payload id' do
|
34
|
+
subject.enqueue(payload)
|
35
|
+
payload.id.should_not be_nil
|
25
36
|
end
|
26
37
|
|
27
38
|
it 'should add a job to the queue' do
|
28
|
-
|
29
|
-
|
30
|
-
subject.length(
|
39
|
+
subject.enqueue(payload)
|
40
|
+
payload.queue.should == 'default'
|
41
|
+
subject.length(payload.queue).should == 1
|
31
42
|
end
|
32
43
|
|
33
44
|
it 'should add queue to list of queues' do
|
34
45
|
subject.queues.should == []
|
35
|
-
|
36
|
-
subject.queues.should == [
|
46
|
+
subject.enqueue(payload)
|
47
|
+
subject.queues.should == [payload.queue]
|
37
48
|
end
|
38
49
|
|
39
50
|
it 'should assign a different job id for the same job enqueue multiple times' do
|
40
|
-
subject.enqueue(
|
51
|
+
subject.enqueue(payload).id.should_not == subject.enqueue(payload).id
|
41
52
|
end
|
42
53
|
end
|
43
54
|
|
44
55
|
describe 'length' do
|
45
56
|
it 'should use the default queue by default' do
|
46
57
|
subject.length.should == 0
|
47
|
-
subject.enqueue(
|
58
|
+
subject.enqueue(payload)
|
48
59
|
subject.length.should == 1
|
49
60
|
end
|
50
61
|
end
|
51
62
|
|
52
63
|
describe 'clear' do
|
53
64
|
it 'should clear jobs for given queue' do
|
54
|
-
|
55
|
-
subject.length(
|
56
|
-
subject.clear(
|
57
|
-
subject.length(
|
58
|
-
subject.queues.should_not include(
|
65
|
+
subject.enqueue payload
|
66
|
+
subject.length(payload.queue).should == 1
|
67
|
+
subject.clear(payload.queue)
|
68
|
+
subject.length(payload.queue).should == 0
|
69
|
+
subject.queues.should_not include(payload.queue)
|
59
70
|
end
|
60
71
|
|
61
72
|
it 'should not clear jobs for a different queue' do
|
62
|
-
|
73
|
+
subject.enqueue(payload)
|
63
74
|
subject.clear('other')
|
64
|
-
subject.length(
|
75
|
+
subject.length(payload.queue).should == 1
|
65
76
|
end
|
66
77
|
|
67
78
|
it 'should clear all queues without any args' do
|
68
|
-
subject.enqueue(
|
69
|
-
subject.enqueue(CustomQueue).queue.should == 'custom'
|
79
|
+
subject.enqueue(payload).queue.should == 'default'
|
80
|
+
subject.enqueue(Qu::Payload.new(:klass => CustomQueue)).queue.should == 'custom'
|
70
81
|
subject.length('default').should == 1
|
71
82
|
subject.length('custom').should == 1
|
72
83
|
subject.clear
|
@@ -75,16 +86,16 @@ shared_examples_for 'a backend' do
|
|
75
86
|
end
|
76
87
|
|
77
88
|
it 'should clear failed queue without any args' do
|
78
|
-
|
79
|
-
subject.failed(
|
89
|
+
subject.enqueue(payload)
|
90
|
+
subject.failed(payload, Exception.new)
|
80
91
|
subject.length('failed').should == 1
|
81
92
|
subject.clear
|
82
93
|
subject.length('failed').should == 0
|
83
94
|
end
|
84
95
|
|
85
96
|
it 'should not clear failed queue with specified queues' do
|
86
|
-
|
87
|
-
subject.failed(
|
97
|
+
subject.enqueue(payload)
|
98
|
+
subject.failed(payload, Exception.new)
|
88
99
|
subject.length('failed').should == 1
|
89
100
|
subject.clear('default')
|
90
101
|
subject.length('failed').should == 1
|
@@ -93,26 +104,26 @@ shared_examples_for 'a backend' do
|
|
93
104
|
|
94
105
|
describe 'reserve' do
|
95
106
|
before do
|
96
|
-
|
107
|
+
subject.enqueue(payload)
|
97
108
|
end
|
98
109
|
|
99
110
|
it 'should return next job' do
|
100
|
-
subject.reserve(worker).id.should ==
|
111
|
+
subject.reserve(worker).id.should == payload.id
|
101
112
|
end
|
102
113
|
|
103
114
|
it 'should not return an already reserved job' do
|
104
|
-
|
115
|
+
subject.enqueue(payload)
|
105
116
|
subject.reserve(worker).id.should_not == subject.reserve(worker).id
|
106
117
|
end
|
107
118
|
|
108
119
|
it 'should return next job in given queues' do
|
109
|
-
subject.enqueue
|
110
|
-
|
111
|
-
subject.enqueue
|
120
|
+
subject.enqueue(payload.dup)
|
121
|
+
custom = subject.enqueue(Qu::Payload.new(:klass => CustomQueue))
|
122
|
+
subject.enqueue(payload.dup)
|
112
123
|
|
113
124
|
worker = Qu::Worker.new('custom', 'default')
|
114
125
|
|
115
|
-
subject.reserve(worker).id.should ==
|
126
|
+
subject.reserve(worker).id.should == custom.id
|
116
127
|
end
|
117
128
|
|
118
129
|
it 'should not return job from different queue' do
|
@@ -143,15 +154,15 @@ shared_examples_for 'a backend' do
|
|
143
154
|
end
|
144
155
|
|
145
156
|
describe 'failed' do
|
146
|
-
let(:
|
157
|
+
let(:payload) { Qu::Payload.new(:id => '1', :klass => SimpleJob) }
|
147
158
|
|
148
159
|
it 'should add to failure queue' do
|
149
|
-
subject.failed(
|
160
|
+
subject.failed(payload, Exception.new)
|
150
161
|
subject.length('failed').should == 1
|
151
162
|
end
|
152
163
|
|
153
164
|
it 'should not add failed queue to the list of queues' do
|
154
|
-
subject.failed(
|
165
|
+
subject.failed(payload, Exception.new)
|
155
166
|
subject.queues.should_not include('failed')
|
156
167
|
end
|
157
168
|
end
|
@@ -164,45 +175,45 @@ shared_examples_for 'a backend' do
|
|
164
175
|
|
165
176
|
describe 'release' do
|
166
177
|
before do
|
167
|
-
subject.enqueue
|
178
|
+
subject.enqueue(payload)
|
168
179
|
end
|
169
180
|
|
170
181
|
it 'should add the job back on the queue' do
|
171
|
-
|
172
|
-
subject.length(
|
173
|
-
subject.release(
|
174
|
-
subject.length(
|
182
|
+
subject.reserve(worker).id.should == payload.id
|
183
|
+
subject.length(payload.queue).should == 0
|
184
|
+
subject.release(payload)
|
185
|
+
subject.length(payload.queue).should == 1
|
175
186
|
end
|
176
187
|
end
|
177
188
|
|
178
189
|
describe 'requeue' do
|
179
190
|
context 'with a failed job' do
|
180
191
|
before do
|
181
|
-
subject.enqueue(
|
182
|
-
|
183
|
-
subject.failed(
|
192
|
+
subject.enqueue(payload)
|
193
|
+
subject.reserve(worker).id.should == payload.id
|
194
|
+
subject.failed(payload, Exception.new)
|
184
195
|
end
|
185
196
|
|
186
197
|
it 'should add the job back on the queue' do
|
187
|
-
subject.length(
|
188
|
-
subject.requeue(
|
189
|
-
subject.length(
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
198
|
+
subject.length(payload.queue).should == 0
|
199
|
+
subject.requeue(payload.id)
|
200
|
+
subject.length(payload.queue).should == 1
|
201
|
+
|
202
|
+
p = subject.reserve(worker)
|
203
|
+
p.should be_instance_of(Qu::Payload)
|
204
|
+
p.id.should == payload.id
|
205
|
+
p.klass.should == payload.klass
|
206
|
+
p.args.should == payload.args
|
196
207
|
end
|
197
208
|
|
198
209
|
it 'should remove the job from the failed jobs' do
|
199
210
|
subject.length('failed').should == 1
|
200
|
-
subject.requeue(
|
211
|
+
subject.requeue(payload.id)
|
201
212
|
subject.length('failed').should == 0
|
202
213
|
end
|
203
214
|
|
204
215
|
it 'should return the job' do
|
205
|
-
subject.requeue(
|
216
|
+
subject.requeue(payload.id).id.should == payload.id
|
206
217
|
end
|
207
218
|
end
|
208
219
|
|
@@ -214,8 +225,6 @@ shared_examples_for 'a backend' do
|
|
214
225
|
end
|
215
226
|
|
216
227
|
describe 'register_worker' do
|
217
|
-
let(:worker) { Qu::Worker.new('default') }
|
218
|
-
|
219
228
|
it 'should add worker to array of workers' do
|
220
229
|
subject.register_worker(worker)
|
221
230
|
subject.workers.size.should == 1
|
@@ -234,10 +243,10 @@ shared_examples_for 'a backend' do
|
|
234
243
|
end
|
235
244
|
|
236
245
|
describe 'unregister_worker' do
|
237
|
-
before { subject.register_worker
|
246
|
+
before { subject.register_worker(worker) }
|
238
247
|
|
239
248
|
it 'should remove worker' do
|
240
|
-
subject.unregister_worker(worker
|
249
|
+
subject.unregister_worker(worker)
|
241
250
|
subject.workers.size.should == 0
|
242
251
|
end
|
243
252
|
|
@@ -245,7 +254,7 @@ shared_examples_for 'a backend' do
|
|
245
254
|
other_worker = Qu::Worker.new('other')
|
246
255
|
subject.register_worker(other_worker)
|
247
256
|
subject.workers.size.should == 2
|
248
|
-
subject.unregister_worker(other_worker
|
257
|
+
subject.unregister_worker(other_worker)
|
249
258
|
subject.workers.size.should == 1
|
250
259
|
subject.workers.first.id.should == worker.id
|
251
260
|
end
|
data/lib/qu/logger.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Qu
|
2
|
+
module Logger
|
3
|
+
def logger
|
4
|
+
Qu.logger
|
5
|
+
end
|
6
|
+
|
7
|
+
def log_exception(exception)
|
8
|
+
message = "\n#{exception.class} (#{exception.message}):\n "
|
9
|
+
message << clean_backtrace(exception).join("\n ") << "\n\n"
|
10
|
+
logger.fatal(message)
|
11
|
+
end
|
12
|
+
|
13
|
+
def clean_backtrace(exception)
|
14
|
+
defined?(Rails) && Rails.respond_to?(:backtrace_cleaner) ?
|
15
|
+
Rails.backtrace_cleaner.clean(exception.backtrace) :
|
16
|
+
exception.backtrace
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -1,11 +1,18 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
1
3
|
module Qu
|
2
|
-
class
|
3
|
-
|
4
|
+
class Payload < OpenStruct
|
5
|
+
include Logger
|
6
|
+
|
7
|
+
undef_method(:id) if method_defined?(:id)
|
4
8
|
|
5
|
-
def initialize(
|
6
|
-
|
9
|
+
def initialize(options = {})
|
10
|
+
super
|
11
|
+
self.args ||= []
|
12
|
+
end
|
7
13
|
|
8
|
-
|
14
|
+
def klass
|
15
|
+
constantize(super)
|
9
16
|
end
|
10
17
|
|
11
18
|
def queue
|
@@ -16,16 +23,25 @@ module Qu
|
|
16
23
|
klass.perform(*args)
|
17
24
|
Qu.backend.completed(self)
|
18
25
|
rescue Qu::Worker::Abort
|
26
|
+
logger.debug "Releasing job #{self}"
|
19
27
|
Qu.backend.release(self)
|
20
28
|
raise
|
21
29
|
rescue Exception => e
|
30
|
+
logger.fatal "Job #{self} failed"
|
31
|
+
log_exception(e)
|
22
32
|
Qu.failure.create(self, e) if Qu.failure
|
23
33
|
Qu.backend.failed(self, e)
|
24
34
|
end
|
25
35
|
|
36
|
+
def to_s
|
37
|
+
"#{id}:#{klass}:#{args.inspect}"
|
38
|
+
end
|
39
|
+
|
26
40
|
protected
|
27
41
|
|
28
42
|
def constantize(class_name)
|
43
|
+
return unless class_name
|
44
|
+
return class_name if class_name.is_a?(Class)
|
29
45
|
constant = Object
|
30
46
|
class_name.split('::').each do |name|
|
31
47
|
constant = constant.const_get(name) || constant.const_missing(name)
|
data/lib/qu/railtie.rb
CHANGED
data/lib/qu/tasks.rb
CHANGED
data/lib/qu/version.rb
CHANGED
data/lib/qu/worker.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Qu
|
2
2
|
class Worker
|
3
|
+
include Logger
|
4
|
+
|
3
5
|
attr_accessor :queues
|
4
6
|
|
5
7
|
class Abort < Exception
|
@@ -22,23 +24,34 @@ module Qu
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def handle_signals
|
27
|
+
logger.debug "Worker #{id} registering traps for INT and TERM signals"
|
25
28
|
%W(INT TERM).each do |sig|
|
26
|
-
trap(sig)
|
29
|
+
trap(sig) do
|
30
|
+
logger.info "Worker #{id} received #{sig}, shutting down"
|
31
|
+
raise Abort
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
30
36
|
def work_off
|
37
|
+
logger.debug "Worker #{id} working of all jobs"
|
31
38
|
while job = Qu.reserve(self, :block => false)
|
39
|
+
logger.debug "Worker #{id} reserved job #{job}"
|
32
40
|
job.perform
|
41
|
+
logger.debug "Worker #{id} completed job #{job}"
|
33
42
|
end
|
34
43
|
end
|
35
44
|
|
36
45
|
def work
|
46
|
+
logger.debug "Worker #{id} waiting for next job"
|
37
47
|
job = Qu.reserve(self)
|
48
|
+
logger.debug "Worker #{id} reserved job #{job}"
|
38
49
|
job.perform
|
50
|
+
logger.debug "Worker #{id} completed job #{job}"
|
39
51
|
end
|
40
52
|
|
41
53
|
def start
|
54
|
+
logger.warn "Worker #{id} starting"
|
42
55
|
handle_signals
|
43
56
|
Qu.backend.register_worker(self)
|
44
57
|
loop { work }
|
@@ -46,10 +59,11 @@ module Qu
|
|
46
59
|
# Ok, we'll shut down, but give us a sec
|
47
60
|
ensure
|
48
61
|
Qu.backend.unregister_worker(self)
|
62
|
+
logger.debug "Worker #{id} done"
|
49
63
|
end
|
50
64
|
|
51
65
|
def id
|
52
|
-
"#{hostname}:#{pid}:#{queues.join(',')}"
|
66
|
+
@id ||= "#{hostname}:#{pid}:#{queues.join(',')}"
|
53
67
|
end
|
54
68
|
|
55
69
|
def pid
|
data/qu.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
3
|
require "qu/version"
|
4
4
|
|
5
|
-
plugins = Dir['qu-*.gemspec'].map {|gemspec| gemspec.scan(/qu-(.*)\.gemspec/).
|
5
|
+
plugins = Dir['qu-*.gemspec'].map {|gemspec| gemspec.scan(/qu-(.*)\.gemspec/).flatten.first }.join('\|')
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "qu"
|
@@ -1,34 +1,42 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Qu::
|
3
|
+
describe Qu::Payload do
|
4
4
|
class MyJob
|
5
5
|
@queue = :custom
|
6
6
|
end
|
7
7
|
|
8
|
+
it 'should default id to nil' do
|
9
|
+
Qu::Payload.new.id.should == nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should allow id to be set' do
|
13
|
+
Qu::Payload.new(:id => 5).id.should == 5
|
14
|
+
end
|
15
|
+
|
8
16
|
describe 'queue' do
|
9
17
|
it 'should default to "default"' do
|
10
|
-
Qu::
|
18
|
+
Qu::Payload.new.queue.should == 'default'
|
11
19
|
end
|
12
20
|
|
13
|
-
it 'should get queue from
|
14
|
-
Qu::
|
21
|
+
it 'should get queue from instance variable' do
|
22
|
+
Qu::Payload.new(:klass => MyJob).queue.should == 'custom'
|
15
23
|
end
|
16
24
|
end
|
17
25
|
|
18
26
|
describe 'klass' do
|
19
27
|
it 'should constantize string' do
|
20
|
-
Qu::
|
28
|
+
Qu::Payload.new(:klass => 'MyJob').klass.should == MyJob
|
21
29
|
end
|
22
30
|
|
23
|
-
it 'should find namespaced
|
24
|
-
Qu::
|
31
|
+
it 'should find namespaced class' do
|
32
|
+
Qu::Payload.new(:klass => 'Qu::Payload').klass.should == Qu::Payload
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
28
36
|
describe 'perform' do
|
29
|
-
subject { Qu::
|
37
|
+
subject { Qu::Payload.new(:klass => SimpleJob) }
|
30
38
|
|
31
|
-
it 'should call .perform on
|
39
|
+
it 'should call .perform on class with args' do
|
32
40
|
subject.args = ['a', 'b']
|
33
41
|
SimpleJob.should_receive(:perform).with('a', 'b')
|
34
42
|
subject.perform
|
data/spec/qu/worker_spec.rb
CHANGED
data/spec/qu_spec.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Qu do
|
4
|
-
%w(
|
4
|
+
%w(length queues reserve clear connection=).each do |method|
|
5
5
|
it "should delegate #{method} to backend" do
|
6
6
|
Qu.backend.should_receive(method).with(:arg)
|
7
7
|
Qu.send(method, :arg)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
describe 'enqueue' do
|
12
|
+
it 'should call enqueue on backend with a payload' do
|
13
|
+
Qu.backend.should_receive(:enqueue) do |payload|
|
14
|
+
payload.should be_instance_of(Qu::Payload)
|
15
|
+
payload.klass.should == SimpleJob
|
16
|
+
payload.args.should == [9,8]
|
17
|
+
end
|
18
|
+
|
19
|
+
Qu.enqueue SimpleJob, 9, 8
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
11
23
|
describe 'configure' do
|
12
24
|
it 'should yield Qu' do
|
13
25
|
Qu.configure do |c|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,47 +1,34 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: qu
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Brandon Keepers
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-10-03 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: multi_json
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70136826415300 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70136826415300
|
25
|
+
description: ''
|
26
|
+
email:
|
37
27
|
- brandon@opensoul.org
|
38
28
|
executables: []
|
39
|
-
|
40
29
|
extensions: []
|
41
|
-
|
42
30
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
31
|
+
files:
|
45
32
|
- .gitignore
|
46
33
|
- Gemfile
|
47
34
|
- Guardfile
|
@@ -51,52 +38,43 @@ files:
|
|
51
38
|
- lib/qu/backend/base.rb
|
52
39
|
- lib/qu/backend/spec.rb
|
53
40
|
- lib/qu/failure.rb
|
54
|
-
- lib/qu/
|
41
|
+
- lib/qu/logger.rb
|
42
|
+
- lib/qu/payload.rb
|
55
43
|
- lib/qu/railtie.rb
|
56
44
|
- lib/qu/tasks.rb
|
57
45
|
- lib/qu/version.rb
|
58
46
|
- lib/qu/worker.rb
|
59
47
|
- qu.gemspec
|
60
|
-
- spec/qu/
|
48
|
+
- spec/qu/payload_spec.rb
|
61
49
|
- spec/qu/worker_spec.rb
|
62
50
|
- spec/qu_spec.rb
|
63
51
|
- spec/spec_helper.rb
|
64
|
-
has_rdoc: true
|
65
52
|
homepage: http://github.com/bkeepers/qu
|
66
53
|
licenses: []
|
67
|
-
|
68
54
|
post_install_message:
|
69
55
|
rdoc_options: []
|
70
|
-
|
71
|
-
require_paths:
|
56
|
+
require_paths:
|
72
57
|
- lib
|
73
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
59
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
|
80
|
-
- 0
|
81
|
-
version: "0"
|
82
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
65
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
version: "0"
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
91
70
|
requirements: []
|
92
|
-
|
93
71
|
rubyforge_project:
|
94
|
-
rubygems_version: 1.6
|
72
|
+
rubygems_version: 1.8.6
|
95
73
|
signing_key:
|
96
74
|
specification_version: 3
|
97
|
-
summary:
|
98
|
-
test_files:
|
99
|
-
- spec/qu/
|
75
|
+
summary: ''
|
76
|
+
test_files:
|
77
|
+
- spec/qu/payload_spec.rb
|
100
78
|
- spec/qu/worker_spec.rb
|
101
79
|
- spec/qu_spec.rb
|
102
80
|
- spec/spec_helper.rb
|