asynchronic 1.0.0 → 1.1.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: f1f6b6846abc0d662921131cdab188869fa36354
4
- data.tar.gz: abaa211fac95e8fdd69795859341fb57d09547b4
3
+ metadata.gz: e646437579de28c6832604a206c25454a26ce1e8
4
+ data.tar.gz: 8b72d178ea9f74359ab02b97c8212a5527ffa8cc
5
5
  SHA512:
6
- metadata.gz: f484b72c6ed24f16b6633fe42b63ffecdcb9d1bcbce4345a62980b648233a5f76abaf0bd2ecbb534500645609a1d856e4169ba3d7d4fa7a2ba2036e05611a071
7
- data.tar.gz: 674e42cba4808664ea3d5e006d2737e813c28a5a348de533bbcaf18606200b2d3cf5a2a357bf4d1102f0212018caa782d54cdc55df41f5c3330b6cf00311d445
6
+ metadata.gz: 3d0b532a8be503af8223bb9884895166ccb114ec61c7fa01013775456300d66e2d302d09ceb518adf4ff880e2431030ed6e52bedb6489487aa1322031587fbb4
7
+ data.tar.gz: eed82387721af34efa9db5dd459068272042ff9cd73d0a57e4e541d2f0fca55189dc4ae20893e916201f66098b45224eb7600d269a9fea8fe6e5ba70701bf9dd
@@ -74,7 +74,7 @@ module Asynchronic
74
74
 
75
75
  def enqueue
76
76
  queued!
77
- environment.enqueue id, queue || type.queue
77
+ environment.enqueue id, queue
78
78
  end
79
79
 
80
80
  def execute
@@ -112,7 +112,7 @@ module Asynchronic
112
112
  new(environment, id) do
113
113
  self.type = type
114
114
  self.name = params.delete(:alias) || type
115
- self.queue = params.delete :queue
115
+ self.queue = params.delete(:queue) || type.queue || parent_queue
116
116
  self.dependencies = Array(params.delete(:dependencies)) | Array(params.delete(:dependency)) | infer_dependencies(params)
117
117
  self.params = params
118
118
  pending!
@@ -180,5 +180,9 @@ module Asynchronic
180
180
  .map { |v| Process.new(environment, v.data_store.scope).name }
181
181
  end
182
182
 
183
+ def parent_queue
184
+ parent.queue if parent
185
+ end
186
+
183
187
  end
184
188
  end
@@ -1,3 +1,3 @@
1
1
  module Asynchronic
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
data/spec/jobs.rb CHANGED
@@ -204,4 +204,25 @@ class WithRetriesJob < Asynchronic::Job
204
204
  @counter
205
205
  end
206
206
  end
207
+ end
208
+
209
+ class NestedJobWithDifferentsQueues < Asynchronic::Job
210
+ def call
211
+ async Level1, input: params[:input]
212
+ result Level1
213
+ end
214
+
215
+ class Level1 < Asynchronic::Job
216
+ queue :other_queue
217
+ def call
218
+ async Level2, input: params[:input] + 1
219
+ result Level2
220
+ end
221
+
222
+ class Level2 < Asynchronic::Job
223
+ def call
224
+ params[:input] + 1
225
+ end
226
+ end
227
+ end
207
228
  end
@@ -401,4 +401,49 @@ module LifeCycleExamples
401
401
  queue.must_be_empty
402
402
  end
403
403
 
404
+ it 'Inheritance of queues in processes. Use default queue' do
405
+ process = create NestedJob, input: 100
406
+
407
+ process.queue.must_be_nil
408
+
409
+ process.enqueue
410
+ execute queue
411
+
412
+ process.processes.first.queue.must_be_nil
413
+ execute queue
414
+
415
+ process.processes.first.processes.first.queue.must_be_nil
416
+ execute queue
417
+ end
418
+
419
+ it 'Inheritance of queues in processes. Specify queue in params' do
420
+ process = create NestedJob, {input: 100, queue: :test_queue}
421
+
422
+ process.queue.must_equal :test_queue
423
+
424
+ process.enqueue
425
+ execute queue_engine[:test_queue]
426
+
427
+ process.processes.first.queue.must_equal :test_queue
428
+ execute queue_engine[:test_queue]
429
+
430
+ process.processes.first.processes.first.queue.must_equal :test_queue
431
+ execute queue_engine[:test_queue]
432
+ end
433
+
434
+ it 'Inheritance of queues in processes. Redefine queue in job class' do
435
+ process = create NestedJobWithDifferentsQueues, {input: 100, queue: :test_queue}
436
+
437
+ process.queue.must_equal :test_queue
438
+
439
+ process.enqueue
440
+ execute queue_engine[:test_queue]
441
+
442
+ process.processes.first.queue.must_equal :other_queue
443
+ execute queue_engine[:other_queue]
444
+
445
+ process.processes.first.processes.first.queue.must_equal :other_queue
446
+ execute queue_engine[:other_queue]
447
+ end
448
+
404
449
  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.0.0
4
+ version: 1.1.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: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis