boss_queue 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/boss_queue.gemspec +2 -2
- data/lib/boss_queue/boss_queue.rb +10 -1
- data/lib/boss_queue/job.rb +1 -1
- data/spec/boss_queue_spec.rb +4 -2
- data/spec/job_spec.rb +31 -17
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
data/boss_queue.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "boss_queue"
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Nelson"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-12-23"
|
13
13
|
s.description = "A fault tolerant job queue built around Amazon SQS & DynamoDB"
|
14
14
|
s.email = "daniel@populr.me"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -99,7 +99,16 @@ class BossQueue
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def sqs_queue # :nodoc:
|
102
|
-
@sqs_queue ||=
|
102
|
+
@sqs_queue ||= BossQueue.sqs_queues[BossQueue.sqs_queue_url(queue_name)]
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.sqs_queues # :nodoc:
|
106
|
+
@sqs_queues ||= AWS::SQS.new.queues
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.sqs_queue_url(name) # :nodoc:
|
110
|
+
@url_mapping ||= {}
|
111
|
+
@url_mapping[name] ||= BossQueue.sqs_queues.url_for(name)
|
103
112
|
end
|
104
113
|
|
105
114
|
def self.environment # :nodoc:
|
data/lib/boss_queue/job.rb
CHANGED
@@ -137,7 +137,7 @@ class BossQueue
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def sqs_queue
|
140
|
-
@sqs_queue ||=
|
140
|
+
@sqs_queue ||= BossQueue.sqs_queues[BossQueue.sqs_queue_url(queue_name)]
|
141
141
|
end
|
142
142
|
|
143
143
|
# from ActiveSupport source: http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-constantize
|
data/spec/boss_queue_spec.rb
CHANGED
@@ -250,8 +250,10 @@ describe "BossQueue module" do
|
|
250
250
|
describe "#work" do
|
251
251
|
before(:each) do
|
252
252
|
@sqs_queue = double('queue')
|
253
|
-
|
254
|
-
|
253
|
+
@sqs_queues = double('queues')
|
254
|
+
@sqs_queues.stub(:[]).and_return(@sqs_queue)
|
255
|
+
BossQueue.stub(:sqs_queues).and_return(@sqs_queues)
|
256
|
+
BossQueue.stub(:sqs_queue_url).and_return('queue_url')
|
255
257
|
|
256
258
|
@sqs_message = double('message')
|
257
259
|
@sqs_message.stub(:body).and_return('ijk')
|
data/spec/job_spec.rb
CHANGED
@@ -224,10 +224,13 @@ describe "BossQueue::Job" do
|
|
224
224
|
|
225
225
|
describe "#enqueue" do
|
226
226
|
it "should enqueue id into the SQS queue" do
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
227
|
+
sqs_queue = double('queue')
|
228
|
+
sqs_queues = double('queues')
|
229
|
+
sqs_queues.stub(:[]).and_return(sqs_queue)
|
230
|
+
BossQueue.stub(:sqs_queues).and_return(sqs_queues)
|
231
|
+
BossQueue.stub(:sqs_queue_url).and_return('queue_url')
|
232
|
+
|
233
|
+
sqs_queue.should_receive(:send_message).with('ijk')
|
231
234
|
job = BossQueue::Job.new
|
232
235
|
job.id = 'ijk'
|
233
236
|
job.enqueue
|
@@ -236,30 +239,41 @@ describe "BossQueue::Job" do
|
|
236
239
|
|
237
240
|
describe "#enqueue_with_delay" do
|
238
241
|
it "should enqueue id into the SQS queue with a delay" do
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
242
|
+
sqs_queue = double('queue')
|
243
|
+
sqs_queues = double('queues')
|
244
|
+
sqs_queues.stub(:[]).and_return(sqs_queue)
|
245
|
+
BossQueue.stub(:sqs_queues).and_return(sqs_queues)
|
246
|
+
BossQueue.stub(:sqs_queue_url).and_return('queue_url')
|
247
|
+
|
248
|
+
|
249
|
+
sqs_queue.should_receive(:send_message).with('ijk', :delay_seconds => 60)
|
243
250
|
job = BossQueue::Job.new
|
244
251
|
job.id = 'ijk'
|
245
252
|
job.enqueue_with_delay(60)
|
246
253
|
end
|
247
254
|
|
248
255
|
it "should limit the delay to 15 minutes" do
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
256
|
+
sqs_queue = double('queue')
|
257
|
+
sqs_queues = double('queues')
|
258
|
+
sqs_queues.stub(:[]).and_return(sqs_queue)
|
259
|
+
BossQueue.stub(:sqs_queues).and_return(sqs_queues)
|
260
|
+
BossQueue.stub(:sqs_queue_url).and_return('queue_url')
|
261
|
+
|
262
|
+
|
263
|
+
sqs_queue.should_receive(:send_message).with('ijk', :delay_seconds => 900)
|
253
264
|
job = BossQueue::Job.new
|
254
265
|
job.id = 'ijk'
|
255
266
|
job.enqueue_with_delay(10000)
|
256
267
|
end
|
257
268
|
|
258
269
|
it "should set a negative delay to 0" do
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
270
|
+
sqs_queue = double('queue')
|
271
|
+
sqs_queues = double('queues')
|
272
|
+
sqs_queues.stub(:[]).and_return(sqs_queue)
|
273
|
+
BossQueue.stub(:sqs_queues).and_return(sqs_queues)
|
274
|
+
BossQueue.stub(:sqs_queue_url).and_return('queue_url')
|
275
|
+
|
276
|
+
sqs_queue.should_receive(:send_message).with('ijk', :delay_seconds => 0)
|
263
277
|
job = BossQueue::Job.new
|
264
278
|
job.id = 'ijk'
|
265
279
|
job.enqueue_with_delay(-60)
|
@@ -353,7 +367,7 @@ describe "BossQueue::Job" do
|
|
353
367
|
@job.fail(@err)
|
354
368
|
@job.exception_name.should == @err.class.to_s
|
355
369
|
@job.exception_message.should == @err.message
|
356
|
-
@job.stacktrace.should == @err.backtrace[0,
|
370
|
+
@job.stacktrace.should == @err.backtrace[0, 15].join("\n")
|
357
371
|
end
|
358
372
|
|
359
373
|
it "should call save!" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boss_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
segments:
|
162
162
|
- 0
|
163
|
-
hash:
|
163
|
+
hash: -4280247350962711662
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
none: false
|
166
166
|
requirements:
|