asynchronic 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asynchronic/process.rb +8 -3
- data/lib/asynchronic/version.rb +1 -1
- data/spec/jobs.rb +12 -0
- data/spec/process/life_cycle_examples.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7fb4fd2b230671121e3549ba81e3c1992fdd1a1
|
4
|
+
data.tar.gz: fcf4f6568ada9b633b9c79df8e4454341eddfeb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c52c72ca2da582331203903c69b2943537e4cad741eb9f1271e08c14310433c636c66d459347f45bf6f8ca2f4b96f41a76fa9d6bcbad12036da8e1c1bc58355
|
7
|
+
data.tar.gz: 658d807dfbc86c9751a13b0d50dbfbec2758c190108ab6e0fc084bf0c3a31420b91aff1aff33907a740ea8c25c03076322f4fb04ccaf71439bfe216b90d513d6
|
data/lib/asynchronic/process.rb
CHANGED
@@ -136,7 +136,7 @@ module Asynchronic
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def get(key)
|
139
|
-
data[key]
|
139
|
+
self.data[key]
|
140
140
|
end
|
141
141
|
|
142
142
|
def set(key, value)
|
@@ -192,8 +192,13 @@ module Asynchronic
|
|
192
192
|
|
193
193
|
STATUSES.each do |status|
|
194
194
|
define_method "#{status}!" do
|
195
|
-
|
196
|
-
|
195
|
+
begin
|
196
|
+
job.before_finalize if [:completed, :aborted].include?(status) && job.respond_to?(:before_finalize)
|
197
|
+
self.status = status
|
198
|
+
rescue Exception => exception
|
199
|
+
self.error = Error.new exception
|
200
|
+
self.status = :aborted
|
201
|
+
end
|
197
202
|
end
|
198
203
|
end
|
199
204
|
|
data/lib/asynchronic/version.rb
CHANGED
data/spec/jobs.rb
CHANGED
@@ -383,3 +383,15 @@ class BeforeFinalizeAbortedJob < Asynchronic::Job
|
|
383
383
|
set :key, get(:key) + 1
|
384
384
|
end
|
385
385
|
end
|
386
|
+
|
387
|
+
class BeforeFinalizeRaisesExceptionJob < Asynchronic::Job
|
388
|
+
|
389
|
+
def call
|
390
|
+
nil
|
391
|
+
end
|
392
|
+
|
393
|
+
def before_finalize
|
394
|
+
raise 'Before finalize exception'
|
395
|
+
end
|
396
|
+
|
397
|
+
end
|
@@ -690,4 +690,22 @@ module LifeCycleExamples
|
|
690
690
|
queue.must_be_empty
|
691
691
|
end
|
692
692
|
|
693
|
+
it 'Before finalize raises exception and aborts' do
|
694
|
+
process = create BeforeFinalizeRaisesExceptionJob
|
695
|
+
|
696
|
+
process.must_be_initialized
|
697
|
+
queue.must_be_empty
|
698
|
+
|
699
|
+
process.enqueue
|
700
|
+
|
701
|
+
process.must_be_queued
|
702
|
+
queue.must_enqueued process
|
703
|
+
|
704
|
+
execute queue
|
705
|
+
|
706
|
+
process.must_be_aborted
|
707
|
+
process.real_error.must_equal 'Before finalize exception'
|
708
|
+
queue.must_be_empty
|
709
|
+
end
|
710
|
+
|
693
711
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asynchronic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|