resque-director 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/resque/plugins/director/lifecycle.rb +10 -5
- data/resque-director.gemspec +1 -1
- data/spec/resque/plugins/director/lifecycle_spec.rb +18 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
@@ -10,12 +10,17 @@ module Resque
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
module ClassMethods
|
14
|
-
|
13
|
+
module ClassMethods
|
15
14
|
def push(queue, item)
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
begin
|
16
|
+
if item.respond_to?(:[]=)
|
17
|
+
job_class = constantize(item[:class] || item['class'])
|
18
|
+
if job_class && job_class.ancestors.include?(Resque::Plugins::Director)
|
19
|
+
timestamp = {'resdirecttime' => Time.now.utc.to_i}
|
20
|
+
item[:args] = item[:args].push(timestamp)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
rescue
|
19
24
|
end
|
20
25
|
push_without_lifecycle queue, item
|
21
26
|
end
|
data/resque-director.gemspec
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
class TestNonDirectedJob
|
4
|
+
@queue = :non_direct
|
5
|
+
def self.perform
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
describe Resque::Plugins::Director::Lifecycle do
|
4
10
|
subject { Resque::Plugins::Director::Lifecycle }
|
5
11
|
|
@@ -16,5 +22,17 @@ describe Resque::Plugins::Director::Lifecycle do
|
|
16
22
|
Resque.enqueue(TestJob, "arg1")
|
17
23
|
Resque.pop("test").should == {"args"=>["arg1", {'resdirecttime' => time_stamp}], "class"=>"TestJob"}
|
18
24
|
end
|
25
|
+
|
26
|
+
it "should not add job timestamps to non directed jobs" do
|
27
|
+
Resque.enqueue(TestNonDirectedJob, "arg1")
|
28
|
+
Resque.pop("non_direct").should == {"args"=>["arg1"], "class"=>"TestNonDirectedJob"}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should not add job timestamps that throw exceptions to direction logic" do
|
32
|
+
TestNonDirectedJob.stub(:ancestors).and_throw(:Exception)
|
33
|
+
Resque.enqueue(TestNonDirectedJob, "arg1")
|
34
|
+
|
35
|
+
Resque.pop("non_direct").should == {"args"=>["arg1"], "class"=>"TestNonDirectedJob"}
|
36
|
+
end
|
19
37
|
end
|
20
38
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-director
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nolan Frausto
|