delayed_job_extras 0.9.17 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/delayed_job_extras/action_mailer.rb +3 -1
- data/lib/delayed_job_extras/acts_as_paranoid.rb +27 -0
- data/lib/delayed_job_extras/extras.rb +12 -1
- data/lib/delayed_job_extras/hoptoad.rb +27 -21
- data/lib/delayed_job_extras/worker.rb +21 -0
- data/lib/delayed_job_extras.rb +1 -1
- metadata +3 -3
- data/lib/delayed_job_extras/is_paranoid.rb +0 -19
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
# If the is_paranoid gem is available
|
3
|
+
# let's use it so we can have a record of the
|
4
|
+
# tasks that have been performed.
|
5
|
+
if defined?(Caboose::Acts::Paranoid)
|
6
|
+
|
7
|
+
DJ::Worker.logger.info "Adding acts_as_paranoid support to Delayed::Job"
|
8
|
+
|
9
|
+
begin
|
10
|
+
module Delayed
|
11
|
+
class Job
|
12
|
+
include HoptoadNotifier::Catcher
|
13
|
+
|
14
|
+
acts_as_paranoid
|
15
|
+
|
16
|
+
end # Job
|
17
|
+
end # Delayed
|
18
|
+
rescue Exception => e
|
19
|
+
DJ::Worker.logger.error(e)
|
20
|
+
raise e
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
rescue Exception => e
|
27
|
+
end
|
@@ -19,6 +19,7 @@ module Delayed
|
|
19
19
|
attr_accessor :__original_args
|
20
20
|
attr_accessor :__re_enqueue_block
|
21
21
|
attr_accessor :re_enqueuable
|
22
|
+
attr_accessor :id
|
22
23
|
|
23
24
|
def priority
|
24
25
|
case @priority
|
@@ -40,7 +41,11 @@ module Delayed
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def worker_class_name
|
43
|
-
|
44
|
+
if self.id
|
45
|
+
@worker_class_name ||= File.join(self.class.to_s.underscore, self.id.to_s)
|
46
|
+
else
|
47
|
+
@worker_class_name ||= self.class.to_s.underscore
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
46
51
|
def enqueue(priority = self.priority, run_at = self.run_at)
|
@@ -82,6 +87,12 @@ module Delayed
|
|
82
87
|
end
|
83
88
|
end
|
84
89
|
|
90
|
+
def is_unique
|
91
|
+
define_method('unique?') do
|
92
|
+
return true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
85
96
|
def enqueue(*args)
|
86
97
|
self.new(*args).enqueue
|
87
98
|
end
|
@@ -2,31 +2,37 @@ begin
|
|
2
2
|
|
3
3
|
DJ::Worker.logger.info "Adding Hoptoad support to Delayed::Job"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
begin
|
6
|
+
module Delayed
|
7
|
+
class Job
|
8
|
+
|
9
|
+
def invoke_job_with_hoptoad
|
10
|
+
if defined?(HoptoadNotifier)
|
11
|
+
Delayed::Job.send(:define_method, :invoke_job_with_hoptoad) do
|
12
|
+
begin
|
13
|
+
invoke_job_without_hoptoad
|
14
|
+
rescue Exception => e
|
15
|
+
HoptoadNotifier.notify(e, :cgi_data => self.attributes)
|
16
|
+
raise e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
else
|
20
|
+
Delayed::Job.send(:define_method, :invoke_job_with_hoptoad) do
|
12
21
|
invoke_job_without_hoptoad
|
13
|
-
rescue Exception => e
|
14
|
-
HoptoadNotifier.notify(e, :cgi_data => self.attributes)
|
15
|
-
raise e
|
16
22
|
end
|
17
23
|
end
|
18
|
-
|
19
|
-
Delayed::Job.send(:define_method, :invoke_job_with_hoptoad) do
|
20
|
-
invoke_job_without_hoptoad
|
21
|
-
end
|
24
|
+
invoke_job_with_hoptoad
|
22
25
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
|
27
|
+
alias_method_chain :invoke_job, :hoptoad
|
28
|
+
|
29
|
+
end # Job
|
30
|
+
end # Delayed
|
31
|
+
rescue Exception => e
|
32
|
+
DJ::Worker.logger.error(e)
|
33
|
+
raise e
|
34
|
+
end
|
35
|
+
|
30
36
|
|
31
37
|
rescue Exception => e
|
32
38
|
end
|
@@ -2,5 +2,26 @@ module DJ
|
|
2
2
|
class Worker
|
3
3
|
include Delayed::Job::Extras
|
4
4
|
|
5
|
+
attr_accessor :attributes
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
self.attributes = attributes
|
9
|
+
self.attributes = self.attributes.stringify_keys
|
10
|
+
self.id = self.attributes['id']
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing(sym, *args, &block)
|
14
|
+
attribute = sym.to_s
|
15
|
+
case attribute
|
16
|
+
when /(.+)\=$/
|
17
|
+
self.attributes[$1] = args.first
|
18
|
+
when /(.+)\?$/
|
19
|
+
# self.attributes.has_key?($1.to_sym)
|
20
|
+
return self.attributes[$1]
|
21
|
+
else
|
22
|
+
return self.attributes[attribute]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
5
26
|
end # Worker
|
6
27
|
end # DJ
|
data/lib/delayed_job_extras.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_extras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markbates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-15 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,9 +33,9 @@ extra_rdoc_files:
|
|
33
33
|
- LICENSE
|
34
34
|
files:
|
35
35
|
- lib/delayed_job_extras/action_mailer.rb
|
36
|
+
- lib/delayed_job_extras/acts_as_paranoid.rb
|
36
37
|
- lib/delayed_job_extras/extras.rb
|
37
38
|
- lib/delayed_job_extras/hoptoad.rb
|
38
|
-
- lib/delayed_job_extras/is_paranoid.rb
|
39
39
|
- lib/delayed_job_extras/job.rb
|
40
40
|
- lib/delayed_job_extras/performable_method.rb
|
41
41
|
- lib/delayed_job_extras/worker.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
# If the is_paranoid gem is available
|
3
|
-
# let's use it so we can have a record of the
|
4
|
-
# tasks that have been performed.
|
5
|
-
require 'is_paranoid'
|
6
|
-
|
7
|
-
DJ::Worker.logger.info "Adding is_paranoid support to Delayed::Job"
|
8
|
-
|
9
|
-
module Delayed
|
10
|
-
class Job
|
11
|
-
include HoptoadNotifier::Catcher
|
12
|
-
|
13
|
-
is_paranoid
|
14
|
-
|
15
|
-
end # Job
|
16
|
-
end # Delayed
|
17
|
-
|
18
|
-
rescue Exception => e
|
19
|
-
end
|