cascade 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cascade/job/callbacks.rb +17 -5
- data/lib/cascade/worker.rb +4 -0
- metadata +3 -3
@@ -4,17 +4,29 @@ module Cascade
|
|
4
4
|
def run_callbacks(action, job_spec)
|
5
5
|
self.class.all_callbacks[action].each do |callback|
|
6
6
|
result = if callback.is_a?(Symbol)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
send(callback, job_spec)
|
8
|
+
else
|
9
|
+
instance_exec job_spec, &callback
|
10
|
+
end
|
11
11
|
return false unless result
|
12
12
|
end
|
13
13
|
true
|
14
14
|
end
|
15
15
|
|
16
16
|
module ClassMethods
|
17
|
-
|
17
|
+
def run_callbacks(action, job_spec)
|
18
|
+
all_callbacks[action].each do |callback|
|
19
|
+
result = if callback.is_a?(Symbol)
|
20
|
+
send(callback, job_spec)
|
21
|
+
else
|
22
|
+
callback.call(job_spec)
|
23
|
+
end
|
24
|
+
return false unless result
|
25
|
+
end
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
%w(before_queue after_fork before_run on_success on_error after_run).each do |action|
|
18
30
|
define_method(action) do |*args, &block|
|
19
31
|
add_callback(action.to_sym, args[0], &block)
|
20
32
|
end
|
data/lib/cascade/worker.rb
CHANGED
@@ -40,6 +40,10 @@ module Cascade
|
|
40
40
|
read, write = IO.pipe
|
41
41
|
|
42
42
|
pid = fork do
|
43
|
+
job_class = job_spec.class_name.constantize
|
44
|
+
if job_class.respond_to?(:after_fork)
|
45
|
+
job_class.run_callbacks(:after_fork, job_spec)
|
46
|
+
end
|
43
47
|
job = job_spec.job
|
44
48
|
$0 = "Cascade::Job : #{name} : #{job.describe}"
|
45
49
|
if run_job(job_spec, job)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cascade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
|
-
requirement: &
|
17
|
+
requirement: &2156454080 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '1.0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156454080
|
26
26
|
description: ''
|
27
27
|
email: andrew@andrewtimberlake.com
|
28
28
|
executables: []
|