asynchronic 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df76d108620383f31881d300c27a58c8ed159ed5
4
- data.tar.gz: 999c8387fca556bed70fc2ac5578a83e1ebc9156
3
+ metadata.gz: 7a56b4d0f2c929275129ed42f2ff2d92e26b9646
4
+ data.tar.gz: 74208ec62350e6bea9f0dcfb512ed6150a2e1517
5
5
  SHA512:
6
- metadata.gz: fe94f5bdce4c457d78d0c46653d8299b23f7ae9ecff911f3d321572921c694e4e96265cbb9c65cd0fc6d925740c4697118fe0222ff3db97a58b4c8874ff2dcbf
7
- data.tar.gz: 0dc6bbd6de6502feee5003452381d18413ede5492ba3a173eba522e2a4080178bce9379f0f1f3efcfe29dfcb92dec47eb98e795f6c2aa384456c3c3713f80b3c
6
+ metadata.gz: 8801974149b1b5715904b908d55f69c57bd922fbb4c4b8aa9586d7164f3a21302d81b63015b548a3a5997fcabf8368296f87ec97b927a943f0b72916014b5762
7
+ data.tar.gz: 08cd125a279e9593c9aec42b8858831762bba28e5cd1c63bf645a1a9177acb00e21db47b5ca890ef8c3930df795526542395b5bf6531758942aff7f68f19915a
@@ -67,6 +67,16 @@ module Asynchronic
67
67
  Process.new environment, id.remove_last(2) if id.nested?
68
68
  end
69
69
 
70
+ def real_error
71
+ childs = processes
72
+
73
+ return error.message if childs.empty?
74
+
75
+ childs.each do |child|
76
+ return child.real_error if child.error
77
+ end
78
+ end
79
+
70
80
  def dependencies
71
81
  return [] unless parent
72
82
  data_store[:dependencies].map { |d| parent[d] }
@@ -1,3 +1,3 @@
1
1
  module Asynchronic
2
- VERSION = '1.2.2'
2
+ VERSION = '1.3.0'
3
3
  end
data/spec/jobs.rb CHANGED
@@ -237,4 +237,75 @@ class DataJob < Asynchronic::Job
237
237
  set :value, params[:input]
238
238
  nil
239
239
  end
240
+ end
241
+
242
+
243
+ class NestedJobWithErrorInChild < Asynchronic::Job
244
+
245
+ def call
246
+ async Child_1
247
+ async Child_2
248
+ async Child_3
249
+ nil
250
+ end
251
+
252
+ class Child_1 < Asynchronic::Job
253
+ def call
254
+ async Child_1_1
255
+ async Child_1_2
256
+ nil
257
+ end
258
+
259
+ class Child_1_1 < Asynchronic::Job
260
+ def call
261
+ nil
262
+ end
263
+ end
264
+
265
+ class Child_1_2 < Asynchronic::Job
266
+ def call
267
+ nil
268
+ end
269
+ end
270
+ end
271
+
272
+ class Child_2 < Asynchronic::Job
273
+ def call
274
+ async Child_2_1
275
+ async Child_2_2
276
+ async Child_2_3
277
+ nil
278
+ end
279
+
280
+ class Child_2_1 < Asynchronic::Job
281
+ def call
282
+ nil
283
+ end
284
+ end
285
+
286
+ class Child_2_2 < Asynchronic::Job
287
+ def call
288
+ raise "Error in Child_2_2"
289
+ end
290
+ end
291
+
292
+ class Child_2_3 < Asynchronic::Job
293
+ def call
294
+ nil
295
+ end
296
+ end
297
+ end
298
+
299
+ class Child_3 < Asynchronic::Job
300
+ def call
301
+ async Child_3_1
302
+ nil
303
+ end
304
+
305
+ class Child_3_1 < Asynchronic::Job
306
+ def call
307
+ nil
308
+ end
309
+ end
310
+ end
240
311
  end
@@ -462,4 +462,18 @@ module LifeCycleExamples
462
462
  process.data.must_equal text: 'Input was 1', value: 1
463
463
  end
464
464
 
465
+ it 'NestedJobWithErrorInChild' do
466
+ process = create NestedJobWithErrorInChild, queue: :test_queue
467
+
468
+ process.enqueue
469
+
470
+ Timeout.timeout(1) do
471
+ until process.status == :aborted
472
+ execute queue_engine[:test_queue]
473
+ end
474
+ end
475
+
476
+ process.real_error.must_equal "Error in Child_2_2"
477
+ end
478
+
465
479
  end
@@ -8,6 +8,10 @@ describe Asynchronic::QueueEngine::Synchronic do
8
8
  end
9
9
  end
10
10
 
11
+ after do
12
+ Asynchronic.environment.data_store.clear
13
+ end
14
+
11
15
  it 'Original job' do
12
16
  pid = BasicJob.enqueue input: 1
13
17
  process = Asynchronic[pid]
@@ -4,6 +4,11 @@ module WorkerExamples
4
4
  let(:queue_name) { :test_worker }
5
5
  let(:queue) { env.queue queue_name }
6
6
 
7
+ after do
8
+ data_store.clear
9
+ queue_engine.clear
10
+ end
11
+
7
12
  def enqueue_processes
8
13
  processes = 5.times.map do
9
14
  env.create_process(WorkerJob, queue: :test_worker).tap(&:enqueue)
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.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-27 00:00:00.000000000 Z
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis