canvas-jobs 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed/backend/base.rb +8 -6
- data/lib/delayed/lifecycle.rb +2 -0
- data/lib/delayed/plugin.rb +22 -0
- data/lib/delayed/version.rb +1 -1
- data/lib/delayed/worker.rb +6 -0
- data/lib/delayed_job.rb +1 -0
- data/spec/gemfiles/32.gemfile.lock +1 -1
- data/spec/gemfiles/40.gemfile.lock +1 -1
- data/spec/gemfiles/41.gemfile.lock +1 -1
- data/spec/gemfiles/42.gemfile.lock +3 -1
- data/spec/shared/worker.rb +23 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad6300227d1380ed20717f92ebd1d628295685b4
|
4
|
+
data.tar.gz: 6b18acd99fb06b30edcb80ed90fbf117f5f3eab6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e902946c32dcb6ea0be687066837cc94254714df18e9e7a562e2308d563a24382b300990ef1f59d4c9d1c1b6145984a2c7d0d72d7e967ef4e72516a8bc78a0c6
|
7
|
+
data.tar.gz: ebf19119b6be32e917de452611ca1f73b555cfb76616a4caa6c09f0db709afe7059ba2bb26e1beb2ac1819d966be41869f0d8a9bc75931a7910c1d69997b582b
|
data/lib/delayed/backend/base.rb
CHANGED
@@ -219,12 +219,14 @@ module Delayed
|
|
219
219
|
|
220
220
|
# Moved into its own method so that new_relic can trace it.
|
221
221
|
def invoke_job
|
222
|
-
Delayed::
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
222
|
+
Delayed::Worker.lifecycle.run_callbacks(:invoke_job, self) do
|
223
|
+
Delayed::Job.in_delayed_job = true
|
224
|
+
begin
|
225
|
+
payload_object.perform
|
226
|
+
ensure
|
227
|
+
Delayed::Job.in_delayed_job = false
|
228
|
+
::ActiveRecord::Base.clear_active_connections! unless Rails.env.test?
|
229
|
+
end
|
228
230
|
end
|
229
231
|
end
|
230
232
|
|
data/lib/delayed/lifecycle.rb
CHANGED
@@ -6,6 +6,7 @@ module Delayed
|
|
6
6
|
:perform => [:worker, :job],
|
7
7
|
:pop => [:worker],
|
8
8
|
:exceptional_exit => [:worker, :exception],
|
9
|
+
:invoke_job => [:job],
|
9
10
|
}
|
10
11
|
|
11
12
|
def initialize
|
@@ -14,6 +15,7 @@ module Delayed
|
|
14
15
|
|
15
16
|
def reset!
|
16
17
|
@callbacks = EVENTS.keys.inject({}) { |hash, e| hash[e] = Callback.new; hash }
|
18
|
+
Delayed::Worker.plugins.each { |plugin| plugin.reset! }
|
17
19
|
end
|
18
20
|
|
19
21
|
def before(event, &block)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'active_support/core_ext/class/attribute'
|
2
|
+
|
3
|
+
module Delayed
|
4
|
+
class Plugin
|
5
|
+
class_attribute :callback_block
|
6
|
+
|
7
|
+
def self.callbacks(&block)
|
8
|
+
self.callback_block = block
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.inject!
|
12
|
+
unless @injected
|
13
|
+
self.callback_block.call(Delayed::Worker.lifecycle) if self.callback_block
|
14
|
+
end
|
15
|
+
@injected = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.reset!
|
19
|
+
@injected = false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/delayed/version.rb
CHANGED
data/lib/delayed/worker.rb
CHANGED
@@ -3,6 +3,7 @@ module Delayed
|
|
3
3
|
class TimeoutError < RuntimeError; end
|
4
4
|
|
5
5
|
require 'tmpdir'
|
6
|
+
require 'set'
|
6
7
|
|
7
8
|
class Worker
|
8
9
|
attr_reader :config, :queue, :min_priority, :max_priority
|
@@ -20,6 +21,9 @@ class Worker
|
|
20
21
|
end
|
21
22
|
cattr_reader :on_max_failures
|
22
23
|
|
24
|
+
cattr_accessor :plugins
|
25
|
+
self.plugins = Set.new
|
26
|
+
|
23
27
|
def self.lifecycle
|
24
28
|
@lifecycle ||= Delayed::Lifecycle.new
|
25
29
|
end
|
@@ -47,6 +51,8 @@ class Worker
|
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
54
|
+
|
55
|
+
plugins.each { |plugin| plugin.inject! }
|
50
56
|
end
|
51
57
|
|
52
58
|
def name=(name)
|
data/lib/delayed_job.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
canvas-jobs (0.9.
|
4
|
+
canvas-jobs (0.9.9)
|
5
5
|
after_transaction_commit (= 1.0.1)
|
6
6
|
rails (>= 3.2)
|
7
7
|
redis (> 3.0)
|
@@ -130,6 +130,7 @@ GEM
|
|
130
130
|
actionpack (>= 4.0)
|
131
131
|
activesupport (>= 4.0)
|
132
132
|
sprockets (~> 2.8)
|
133
|
+
syck (1.0.4)
|
133
134
|
test_after_commit (0.3.0)
|
134
135
|
activerecord (>= 3.2)
|
135
136
|
thor (0.19.1)
|
@@ -152,6 +153,7 @@ DEPENDENCIES
|
|
152
153
|
rails (~> 4.2.0.beta2)
|
153
154
|
rake
|
154
155
|
rspec
|
156
|
+
syck
|
155
157
|
test_after_commit
|
156
158
|
timecop
|
157
159
|
wwtd
|
data/spec/shared/worker.rb
CHANGED
@@ -288,4 +288,27 @@ shared_examples_for 'Delayed::Worker' do
|
|
288
288
|
worker.queue.should == queue_name
|
289
289
|
end
|
290
290
|
end
|
291
|
+
|
292
|
+
context "plugins" do
|
293
|
+
class TestPlugin < ::Delayed::Plugin
|
294
|
+
cattr_accessor :runs
|
295
|
+
self.runs = 0
|
296
|
+
callbacks do |lifecycle|
|
297
|
+
lifecycle.around(:invoke_job) do |job, *args, &block|
|
298
|
+
TestPlugin.runs += 1
|
299
|
+
block.call(job, *args)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
it "should create and call the plugin callbacks" do
|
305
|
+
TestPlugin.runs = 0
|
306
|
+
Delayed::Worker.plugins << TestPlugin
|
307
|
+
job_create
|
308
|
+
@worker = Delayed::Worker.new(:quiet => true)
|
309
|
+
@worker.run
|
310
|
+
expect(TestPlugin.runs).to eq(1)
|
311
|
+
expect(SimpleJob.runs).to eq(1)
|
312
|
+
end
|
313
|
+
end
|
291
314
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: after_transaction_commit
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- lib/delayed/message_sending.rb
|
255
255
|
- lib/delayed/performable_method.rb
|
256
256
|
- lib/delayed/periodic.rb
|
257
|
+
- lib/delayed/plugin.rb
|
257
258
|
- lib/delayed/pool.rb
|
258
259
|
- lib/delayed/settings.rb
|
259
260
|
- lib/delayed/testing.rb
|
@@ -300,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
301
|
version: '0'
|
301
302
|
requirements: []
|
302
303
|
rubyforge_project:
|
303
|
-
rubygems_version: 2.
|
304
|
+
rubygems_version: 2.4.4
|
304
305
|
signing_key:
|
305
306
|
specification_version: 4
|
306
307
|
summary: Instructure-maintained fork of delayed_job
|
@@ -325,3 +326,4 @@ test_files:
|
|
325
326
|
- spec/shared/worker.rb
|
326
327
|
- spec/shared_jobs_specs.rb
|
327
328
|
- spec/spec_helper.rb
|
329
|
+
has_rdoc:
|