canvas-jobs 0.9.3 → 0.9.4
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/redis/job.rb +1 -3
- data/lib/delayed/periodic.rb +1 -1
- data/lib/delayed/pool.rb +2 -5
- data/lib/delayed/testing.rb +32 -0
- data/lib/delayed/version.rb +1 -1
- data/spec/active_record_job_spec.rb +1 -2
- data/spec/gemfiles/32.gemfile +4 -0
- data/spec/gemfiles/32.gemfile.lock +2 -2
- data/spec/gemfiles/40.gemfile +3 -0
- data/spec/gemfiles/40.gemfile.lock +2 -2
- data/spec/gemfiles/41.gemfile +3 -0
- data/spec/gemfiles/41.gemfile.lock +2 -2
- data/spec/gemfiles/42.gemfile +3 -0
- data/spec/gemfiles/42.gemfile.lock +2 -2
- data/spec/redis_job_spec.rb +1 -1
- data/spec/shared/testing.rb +47 -0
- data/spec/shared_jobs_specs.rb +3 -1
- data/spec/spec_helper.rb +4 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09c716227c64b63dd68ab787a2af74a625f8da29
|
4
|
+
data.tar.gz: f7683091496f7afac5085bb7d38d0eac48a810ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 262577e7b68a7bfd44cea42e3d1cacffb0f6bf4caa4df7ac7c230f560bb11e4f333ff0c19688820c8ce7a675638bbb57eb45c7a3e869f2b0d075553c690c6b26
|
7
|
+
data.tar.gz: ef2c55f222a31b8a38069cb6177efe339251ed37690633a9f1dda4bded4df89de506169317da6ad2c1d3104b8a9c265c8d9432683b732b32dbec557d09bcb382
|
@@ -191,8 +191,6 @@ class Job
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def self.reconnect!
|
194
|
-
self.redis ||= Redis.current
|
195
|
-
|
196
194
|
# redis cluster responds to reconnect directly,
|
197
195
|
# but individual redis needs it to be called on client
|
198
196
|
redis.respond_to?(:reconnect) ?
|
@@ -457,7 +455,7 @@ class Job
|
|
457
455
|
v = send(k)
|
458
456
|
if v.nil?
|
459
457
|
to_delete << k if !new_record? && changed.include?(k.to_s)
|
460
|
-
elsif v.is_a?(ActiveSupport::TimeWithZone)
|
458
|
+
elsif v.is_a?(ActiveSupport::TimeWithZone) || v.is_a?(Time)
|
461
459
|
attrs[k] = v.utc.to_f
|
462
460
|
else
|
463
461
|
attrs[k] = v.as_json
|
data/lib/delayed/periodic.rb
CHANGED
data/lib/delayed/pool.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'erb'
|
1
2
|
require 'optparse'
|
2
3
|
require 'yaml'
|
3
4
|
require 'fileutils'
|
@@ -21,10 +22,6 @@ class Pool
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def run
|
24
|
-
if GC.respond_to?(:copy_on_write_friendly=)
|
25
|
-
GC.copy_on_write_friendly = true
|
26
|
-
end
|
27
|
-
|
28
25
|
op = OptionParser.new do |opts|
|
29
26
|
opts.banner = "Usage #{$0} <command> <options>"
|
30
27
|
opts.separator %{\nWhere <command> is one of:
|
@@ -309,7 +306,7 @@ class Pool
|
|
309
306
|
end
|
310
307
|
|
311
308
|
def read_config(config_filename)
|
312
|
-
config = YAML.
|
309
|
+
config = YAML.load(ERB.new(File.read(config_filename)).result)
|
313
310
|
env = defined?(RAILS_ENV) ? RAILS_ENV : ENV['RAILS_ENV'] || 'development'
|
314
311
|
@config = config[env] || config['default']
|
315
312
|
# Backwards compatibility from when the config was just an array of queues
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Delayed
|
2
|
+
module Testing
|
3
|
+
def self.run_job(job)
|
4
|
+
Delayed::Worker.new.perform(job)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.drain
|
8
|
+
while job = Delayed::Job.get_and_lock_next_available(
|
9
|
+
'spec run_jobs',
|
10
|
+
Delayed::Settings.queue,
|
11
|
+
0,
|
12
|
+
Delayed::MAX_PRIORITY)
|
13
|
+
run_job(job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.track_created
|
18
|
+
job_tracking = JobTracking.track { yield }
|
19
|
+
job_tracking.created
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.clear_all!
|
23
|
+
case Delayed::Job.name
|
24
|
+
when /Redis/
|
25
|
+
Delayed::Job.redis.flushdb
|
26
|
+
when /ActiveRecord/
|
27
|
+
Delayed::Job.delete_all
|
28
|
+
Delayed::Job::Failed.delete_all
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/delayed/version.rb
CHANGED
data/spec/gemfiles/32.gemfile
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
canvas-jobs (0.9.
|
4
|
+
canvas-jobs (0.9.3)
|
5
5
|
after_transaction_commit (= 1.0.1)
|
6
6
|
rails (>= 3.2)
|
7
7
|
redis (> 3.0)
|
8
8
|
redis-scripting (= 1.0.1)
|
9
9
|
rufus-scheduler (= 2.0.6)
|
10
|
-
syck
|
11
10
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
@@ -135,6 +134,7 @@ DEPENDENCIES
|
|
135
134
|
rails (~> 3.2.19)
|
136
135
|
rake
|
137
136
|
rspec
|
137
|
+
syck
|
138
138
|
test_after_commit
|
139
139
|
timecop
|
140
140
|
wwtd
|
data/spec/gemfiles/40.gemfile
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
canvas-jobs (0.9.
|
4
|
+
canvas-jobs (0.9.3)
|
5
5
|
after_transaction_commit (= 1.0.1)
|
6
6
|
rails (>= 3.2)
|
7
7
|
redis (> 3.0)
|
8
8
|
redis-scripting (= 1.0.1)
|
9
9
|
rufus-scheduler (= 2.0.6)
|
10
|
-
syck
|
11
10
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
@@ -123,6 +122,7 @@ DEPENDENCIES
|
|
123
122
|
rails (~> 4.0.10)
|
124
123
|
rake
|
125
124
|
rspec
|
125
|
+
syck
|
126
126
|
test_after_commit
|
127
127
|
timecop
|
128
128
|
wwtd
|
data/spec/gemfiles/41.gemfile
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
canvas-jobs (0.9.
|
4
|
+
canvas-jobs (0.9.3)
|
5
5
|
after_transaction_commit (= 1.0.1)
|
6
6
|
rails (>= 3.2)
|
7
7
|
redis (> 3.0)
|
8
8
|
redis-scripting (= 1.0.1)
|
9
9
|
rufus-scheduler (= 2.0.6)
|
10
|
-
syck
|
11
10
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
@@ -129,6 +128,7 @@ DEPENDENCIES
|
|
129
128
|
rails (~> 4.1.6)
|
130
129
|
rake
|
131
130
|
rspec
|
131
|
+
syck
|
132
132
|
test_after_commit
|
133
133
|
timecop
|
134
134
|
wwtd
|
data/spec/gemfiles/42.gemfile
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../
|
3
3
|
specs:
|
4
|
-
canvas-jobs (0.9.
|
4
|
+
canvas-jobs (0.9.3)
|
5
5
|
after_transaction_commit (= 1.0.1)
|
6
6
|
rails (>= 3.2)
|
7
7
|
redis (> 3.0)
|
8
8
|
redis-scripting (= 1.0.1)
|
9
9
|
rufus-scheduler (= 2.0.6)
|
10
|
-
syck
|
11
10
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
@@ -154,6 +153,7 @@ DEPENDENCIES
|
|
154
153
|
rails (~> 4.2.0.beta2)
|
155
154
|
rake
|
156
155
|
rspec
|
156
|
+
syck
|
157
157
|
test_after_commit
|
158
158
|
timecop
|
159
159
|
wwtd
|
data/spec/redis_job_spec.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
shared_examples_for 'Delayed::Testing' do
|
2
|
+
class TestingWorker
|
3
|
+
cattr_accessor :runs
|
4
|
+
|
5
|
+
def self.run
|
6
|
+
self.runs += 1
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
before do
|
11
|
+
TestingWorker.runs = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.run_job' do
|
15
|
+
it 'should run a single queued job' do
|
16
|
+
job = TestingWorker.send_later_enqueue_args(:run, no_delay: true)
|
17
|
+
Delayed::Testing.run_job(job)
|
18
|
+
expect(TestingWorker.runs).to eq 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.drain' do
|
23
|
+
it 'should run all queued jobs' do
|
24
|
+
3.times { TestingWorker.send_later(:run) }
|
25
|
+
Delayed::Testing.drain
|
26
|
+
expect(TestingWorker.runs).to eq 3
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'track_created' do
|
31
|
+
it 'should return the list of jobs created in the block' do
|
32
|
+
3.times { TestingWorker.send_later(:run) }
|
33
|
+
jobs = Delayed::Testing.track_created { 2.times { TestingWorker.send_later(:run) } }
|
34
|
+
expect(jobs.size).to eq 2
|
35
|
+
expect(jobs.first.tag).to eq "TestingWorker.run"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'clear_all!' do
|
40
|
+
it 'should delete all queued jobs' do
|
41
|
+
3.times { TestingWorker.send_later(:run) }
|
42
|
+
Delayed::Testing.clear_all!
|
43
|
+
Delayed::Testing.drain
|
44
|
+
expect(TestingWorker.runs).to eq 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/shared_jobs_specs.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require File.expand_path('../shared/shared_backend', __FILE__)
|
2
1
|
require File.expand_path('../shared/delayed_batch', __FILE__)
|
3
2
|
require File.expand_path('../shared/delayed_method', __FILE__)
|
4
3
|
require File.expand_path('../shared/performable_method', __FILE__)
|
4
|
+
require File.expand_path('../shared/shared_backend', __FILE__)
|
5
|
+
require File.expand_path('../shared/testing', __FILE__)
|
5
6
|
require File.expand_path('../shared/worker', __FILE__)
|
6
7
|
|
7
8
|
shared_examples_for 'a delayed_jobs implementation' do
|
@@ -10,4 +11,5 @@ shared_examples_for 'a delayed_jobs implementation' do
|
|
10
11
|
include_examples 'random ruby objects'
|
11
12
|
include_examples 'Delayed::PerformableMethod'
|
12
13
|
include_examples 'Delayed::Worker'
|
14
|
+
include_examples 'Delayed::Testing'
|
13
15
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'delayed_job'
|
2
|
+
require 'delayed/testing'
|
2
3
|
|
3
4
|
require 'database_cleaner'
|
4
5
|
require 'test_after_commit'
|
@@ -45,6 +46,8 @@ ActiveRecord::Base.establish_connection({
|
|
45
46
|
|
46
47
|
ActiveRecord::Migrator.migrate("db/migrate")
|
47
48
|
ActiveRecord::Migrator.migrate("spec/migrate")
|
49
|
+
Delayed::Backend::ActiveRecord::Job.reset_column_information
|
50
|
+
Delayed::Backend::ActiveRecord::Job::Failed.reset_column_information
|
48
51
|
|
49
52
|
Time.zone = 'UTC'
|
50
53
|
Rails.logger = Logger.new(nil)
|
@@ -84,7 +87,7 @@ ensure
|
|
84
87
|
end
|
85
88
|
|
86
89
|
def run_job(job)
|
87
|
-
Delayed::
|
90
|
+
Delayed::Testing.run_job(job)
|
88
91
|
end
|
89
92
|
|
90
93
|
require File.expand_path('../sample_jobs', __FILE__)
|
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.4
|
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-10-21 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/periodic.rb
|
255
255
|
- lib/delayed/pool.rb
|
256
256
|
- lib/delayed/settings.rb
|
257
|
+
- lib/delayed/testing.rb
|
257
258
|
- lib/delayed/version.rb
|
258
259
|
- lib/delayed/worker.rb
|
259
260
|
- lib/delayed/yaml_extensions.rb
|
@@ -274,6 +275,7 @@ files:
|
|
274
275
|
- spec/shared/delayed_method.rb
|
275
276
|
- spec/shared/performable_method.rb
|
276
277
|
- spec/shared/shared_backend.rb
|
278
|
+
- spec/shared/testing.rb
|
277
279
|
- spec/shared/worker.rb
|
278
280
|
- spec/shared_jobs_specs.rb
|
279
281
|
- spec/spec_helper.rb
|
@@ -317,6 +319,7 @@ test_files:
|
|
317
319
|
- spec/shared/delayed_method.rb
|
318
320
|
- spec/shared/performable_method.rb
|
319
321
|
- spec/shared/shared_backend.rb
|
322
|
+
- spec/shared/testing.rb
|
320
323
|
- spec/shared/worker.rb
|
321
324
|
- spec/shared_jobs_specs.rb
|
322
325
|
- spec/spec_helper.rb
|