delayed_job_mongoid 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/delayed/backend/mongoid.rb +16 -9
- data/lib/delayed/serialization/mongoid.rb +20 -11
- data/lib/delayed_job_mongoid.rb +1 -0
- metadata +13 -15
- data/spec/spec.opts +0 -1
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module Delayed
|
2
3
|
module Backend
|
3
4
|
module Mongoid
|
@@ -5,14 +6,15 @@ module Delayed
|
|
5
6
|
include ::Mongoid::Document
|
6
7
|
include ::Mongoid::Timestamps
|
7
8
|
include Delayed::Backend::Base
|
8
|
-
field :priority, :type=> Integer, :default => 0
|
9
|
-
field :attempts, :type=> Integer, :default => 0
|
10
|
-
field :handler, :type=> String
|
11
|
-
field :run_at, :type=> Time
|
12
|
-
field :locked_at, :type=> Time
|
13
|
-
field :locked_by, :type=> String
|
14
|
-
field :failed_at, :type=> Time
|
15
|
-
field :last_error, :type=> String
|
9
|
+
field :priority, :type => Integer, :default => 0
|
10
|
+
field :attempts, :type => Integer, :default => 0
|
11
|
+
field :handler, :type => String
|
12
|
+
field :run_at, :type => Time
|
13
|
+
field :locked_at, :type => Time
|
14
|
+
field :locked_by, :type => String
|
15
|
+
field :failed_at, :type => Time
|
16
|
+
field :last_error, :type => String
|
17
|
+
field :queue, :type => String
|
16
18
|
|
17
19
|
index ([[:locked_by, -1], [:priority, 1], [:run_at, 1]])
|
18
20
|
|
@@ -41,6 +43,7 @@ module Delayed
|
|
41
43
|
conditions = {:run_at => {"$lte" => right_now}, :failed_at => nil}
|
42
44
|
(conditions[:priority] ||= {})['$gte'] = Worker.min_priority.to_i if Worker.min_priority
|
43
45
|
(conditions[:priority] ||= {})['$lte'] = Worker.max_priority.to_i if Worker.max_priority
|
46
|
+
(conditions[:queue] ||= {})['$in'] = Worker.queues if Worker.queues.any?
|
44
47
|
|
45
48
|
conditions['$or'] = [
|
46
49
|
{ :locked_by => worker.name },
|
@@ -57,7 +60,7 @@ module Delayed
|
|
57
60
|
|
58
61
|
# Return result as a Mongoid document.
|
59
62
|
# When Mongoid starts supporting findAndModify, this extra step should no longer be necessary.
|
60
|
-
self.find(:first, :conditions => {:_id => result["_id"]})
|
63
|
+
self.find(:first, :conditions => {:_id => result["_id"]}) unless result.nil?
|
61
64
|
rescue Mongo::OperationFailure
|
62
65
|
nil # no jobs available
|
63
66
|
end
|
@@ -68,6 +71,10 @@ module Delayed
|
|
68
71
|
self.collection.update({:locked_by => worker_name}, {"$set" => {:locked_at => nil, :locked_by => nil}}, :multi => true)
|
69
72
|
end
|
70
73
|
|
74
|
+
def reload(*args)
|
75
|
+
reset
|
76
|
+
super
|
77
|
+
end
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
@@ -1,16 +1,25 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
if YAML.parser.class.name =~ /syck/i
|
3
|
+
Mongoid::Document.class_eval do
|
4
|
+
yaml_as "tag:ruby.yaml.org,2002:Mongoid"
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def self.yaml_new(klass, tag, val)
|
7
|
+
begin
|
8
|
+
klass.find(val['attributes']['_id'])
|
9
|
+
rescue Mongoid::Errors::DocumentNotFound
|
10
|
+
raise Delayed::DeserializationError
|
11
|
+
end
|
9
12
|
end
|
10
|
-
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
def to_yaml_properties
|
15
|
+
['@attributes']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
Mongoid::Document.class_eval do
|
20
|
+
def encode_with(coder)
|
21
|
+
coder["attributes"] = @attributes
|
22
|
+
coder.tag = ['!ruby/Mongoid', self.class.name].join(':')
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
|
-
|
data/lib/delayed_job_mongoid.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-11-07 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mongoid
|
17
|
-
requirement: &
|
17
|
+
requirement: &70328152463320 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,21 +22,21 @@ dependencies:
|
|
22
22
|
version: '2.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70328152463320
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: delayed_job
|
28
|
-
requirement: &
|
28
|
+
requirement: &70328152462420 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - =
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.0.0.pre3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70328152462420
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
39
|
-
requirement: &
|
39
|
+
requirement: &70328152461720 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '2.0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70328152461720
|
48
48
|
description:
|
49
49
|
email:
|
50
50
|
- chris@collectiveidea.com
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- lib/delayed/serialization/mongoid.rb
|
60
60
|
- lib/delayed_job_mongoid.rb
|
61
61
|
- spec/delayed_job_mongoid_spec.rb
|
62
|
-
- spec/spec.opts
|
63
62
|
- spec/spec_helper.rb
|
64
63
|
- LICENSE
|
65
64
|
- README.md
|
@@ -78,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
77
|
version: '0'
|
79
78
|
segments:
|
80
79
|
- 0
|
81
|
-
hash: -
|
80
|
+
hash: -3515724282109696220
|
82
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
82
|
none: false
|
84
83
|
requirements:
|
@@ -87,14 +86,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
86
|
version: '0'
|
88
87
|
segments:
|
89
88
|
- 0
|
90
|
-
hash: -
|
89
|
+
hash: -3515724282109696220
|
91
90
|
requirements: []
|
92
91
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.8.
|
92
|
+
rubygems_version: 1.8.11
|
94
93
|
signing_key:
|
95
94
|
specification_version: 3
|
96
95
|
summary: Mongoid backend for delayed_job
|
97
96
|
test_files:
|
98
97
|
- spec/delayed_job_mongoid_spec.rb
|
99
|
-
- spec/spec.opts
|
100
98
|
- spec/spec_helper.rb
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|