mloughran-job_queue 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/lib/job_queue/adapters/amqp_adapter.rb +1 -1
- data/lib/job_queue/adapters/beanstalk_adapter.rb +7 -1
- data/lib/job_queue/adapters/test_adapter.rb +4 -0
- data/lib/job_queue/adapters/verbose_adapter.rb +5 -1
- data/lib/job_queue/job_queue.rb +4 -0
- data/spec/beanstalk_adapter_spec.rb +5 -0
- data/spec/common_adapter_spec.rb +9 -1
- data/spec/test_adapter_spec.rb +2 -0
- metadata +6 -5
data/VERSION.yml
CHANGED
@@ -24,7 +24,7 @@ class JobQueue::BeanstalkAdapter
|
|
24
24
|
begin
|
25
25
|
job = pool.reserve(1)
|
26
26
|
time_left = job.stats["time-left"]
|
27
|
-
JobQueue.logger.
|
27
|
+
JobQueue.logger.debug "Beanstalk received #{job.body}"
|
28
28
|
Timeout::timeout([time_left - 1, 1].max) do
|
29
29
|
yield job.body
|
30
30
|
end
|
@@ -62,6 +62,12 @@ class JobQueue::BeanstalkAdapter
|
|
62
62
|
nil
|
63
63
|
end
|
64
64
|
|
65
|
+
def queue_length(queue)
|
66
|
+
beanstalk_pool.stats_tube(queue)["total-jobs"]
|
67
|
+
rescue Beanstalk::NotFoundError
|
68
|
+
0
|
69
|
+
end
|
70
|
+
|
65
71
|
def beanstalk_pool(queue='default')
|
66
72
|
@beanstalk_pools ||= {}
|
67
73
|
@beanstalk_pools[queue] ||= begin
|
@@ -7,7 +7,7 @@ class JobQueue::VerboseAdapter
|
|
7
7
|
|
8
8
|
end
|
9
9
|
|
10
|
-
def put(string)
|
10
|
+
def put(string, queue, priority, ttr)
|
11
11
|
JobQueue.logger.debug "===== NEW JOB ADDED TO QUEUE ===="
|
12
12
|
JobQueue.logger.debug string
|
13
13
|
JobQueue.logger.debug "===== END OF MESSAGE ============"
|
@@ -16,4 +16,8 @@ class JobQueue::VerboseAdapter
|
|
16
16
|
def subscribe(error_report, &block)
|
17
17
|
raise "Not implemented. Use a better adapter!!"
|
18
18
|
end
|
19
|
+
|
20
|
+
def queue_length(queue)
|
21
|
+
raise "Not supported"
|
22
|
+
end
|
19
23
|
end
|
data/lib/job_queue/job_queue.rb
CHANGED
@@ -218,6 +218,7 @@ describe JobQueue::BeanstalkAdapter do
|
|
218
218
|
|
219
219
|
describe "common" do
|
220
220
|
it_should_behave_like "JobQueue adapter named queues"
|
221
|
+
it_should_behave_like "JobQueue adapter queue length"
|
221
222
|
end
|
222
223
|
|
223
224
|
it "should write onto queue and fetch stuff back off" do
|
@@ -277,6 +278,10 @@ describe JobQueue::BeanstalkAdapter do
|
|
277
278
|
})
|
278
279
|
end
|
279
280
|
|
281
|
+
describe "common" do
|
282
|
+
it_should_behave_like "JobQueue adapter queue length"
|
283
|
+
end
|
284
|
+
|
280
285
|
it "should be possible to put jobs" do
|
281
286
|
JobQueue.put('test')
|
282
287
|
JobQueue.subscribe do |job|
|
data/spec/common_adapter_spec.rb
CHANGED
@@ -51,4 +51,12 @@ shared_examples_for "JobQueue adapter named queues" do
|
|
51
51
|
end
|
52
52
|
}
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
55
|
+
|
56
|
+
shared_examples_for "JobQueue adapter queue length" do
|
57
|
+
it "should report the length of the named queue" do
|
58
|
+
JobQueue.queue_length('test').should == 0
|
59
|
+
5.times { JobQueue.put("hello", :queue => "test") }
|
60
|
+
JobQueue.queue_length('test').should == 5
|
61
|
+
end
|
62
|
+
end
|
data/spec/test_adapter_spec.rb
CHANGED
@@ -10,6 +10,8 @@ describe JobQueue::TestAdapter do
|
|
10
10
|
|
11
11
|
it_should_behave_like "JobQueue adapter named queues"
|
12
12
|
|
13
|
+
it_should_behave_like "JobQueue adapter queue length"
|
14
|
+
|
13
15
|
it "should allow queue inspection as a hash" do
|
14
16
|
JobQueue.adapter.queue.should == []
|
15
17
|
JobQueue.put('hello')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mloughran-job_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martyn Loughran
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -39,8 +39,9 @@ files:
|
|
39
39
|
- spec/spec_helper.rb
|
40
40
|
- spec/test_adapter_spec.rb
|
41
41
|
- spec/verbose_adapter_spec.rb
|
42
|
-
has_rdoc:
|
42
|
+
has_rdoc: false
|
43
43
|
homepage: http://github.com/mloughran/job_queue
|
44
|
+
licenses:
|
44
45
|
post_install_message:
|
45
46
|
rdoc_options:
|
46
47
|
- --inline-source
|
@@ -62,9 +63,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
63
|
requirements: []
|
63
64
|
|
64
65
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.3.5
|
66
67
|
signing_key:
|
67
|
-
specification_version:
|
68
|
+
specification_version: 3
|
68
69
|
summary: JobQueue means you don't have to worry about your queue any more!
|
69
70
|
test_files: []
|
70
71
|
|