concurrent_rails 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afa4c6f568f01ea4ada14fabc78e2e47b7c9a8c3f7ddaa3f3cbc8d3c39dad949
4
- data.tar.gz: cc4165e43a1a6a48fc0dd2bb5b6154257af0ab4d8c32a3620c61b6425e3f32c1
3
+ metadata.gz: 9c9f6c5865a512a981fb3be8f87dadffbc2751c0bb8937b4929af57b3fa691a7
4
+ data.tar.gz: 40e7a30066f9cb04a4093fef697e0e36733d6ca9c7302cbe4b3af4ad7d7e29e7
5
5
  SHA512:
6
- metadata.gz: f68e51f1d5fdc986e4fe70a16beac361f77334727da261ae545dc725f2d9424c9d9b0df7755e7b1e8fb22b010d03db253e1c5206217e13640b246c60c9330177
7
- data.tar.gz: d20462ad8cd6a4b72c86e36654441b53b614e0c98684f4c087d5b7fff251e7dbe8f2e4c1627df623d2e332da8c6017b941d0d922160f78c27023ed942f3adf4f
6
+ metadata.gz: 31ba76250826eab804ac7941e6bd33bf9887d367bcf4dcd1b7dca306b3c44287ca1d5c9c75396e7ed8b88168675251ca8df597b4b175c1aa5cee1287fbbb9181
7
+ data.tar.gz: 3beebfc9b8dc305b555dca571570737247c0409dd67976d0a526d6f37ae64531c2fedafb4de62ef3edb90e867db3ace8131abfa152998b1ff047534c62d7d251
data/README.md CHANGED
@@ -17,26 +17,26 @@ This library provides three classes that will help you run tasks in parallel: `C
17
17
  Similar to other classes, all you have to do is call `.future` helper and pass a block:
18
18
 
19
19
  ```ruby
20
- irb(main):001:0> future = ConcurrentRails::Promises.future { sleep(5); 42 }
21
- => #<ConcurrentRails::Promises:0x00007fe92ea9ff28 @future_instance=#<Con...
20
+ irb(main):001:0> future = ConcurrentRails::Promises.future(5) { |v| sleep(v); 42 }
21
+ => #<ConcurrentRails::Promises:0x00007fed68db66b0 @future_instance=#<Concurrent::Promises::Future
22
22
 
23
- irb(main):003:0> future.state
23
+ irb(main):002:0> future.state
24
24
  => :pending
25
25
 
26
- # After future is processed
27
- irb(main):004:0> future.state
26
+ # After the process slept for 5 seconds
27
+ irb(main):003:0> future.state
28
28
  => :fulfilled
29
29
 
30
- irb(main):005:0> future.value
30
+ irb(main):004:0> future.value
31
31
  => 42
32
32
  ```
33
33
 
34
34
  The benefit of `Promises` over a pure `Future` class is that you can chain futures without blocking the main thread.
35
35
 
36
36
  ```ruby
37
- irb(main):006:0> future = ConcurrentRails::Promises.future { 42 }.then { |v| v * 2 }
37
+ irb(main):001:0> future = ConcurrentRails::Promises.future { 42 }.then { |v| v * 2 }
38
38
  => #<ConcurrentRails::Promises:0x00007fe92eba3460 @future_instance=#...
39
- irb(main):007:0> future.value
39
+ irb(main):002:0> future.value
40
40
  => 84
41
41
  ```
42
42
 
@@ -5,7 +5,6 @@ module ConcurrentRails
5
5
  extend Forwardable
6
6
 
7
7
  def initialize(executor: :io, &block)
8
- @task = block
9
8
  @executor = executor
10
9
  @future = run_on_rails(block)
11
10
  end
@@ -40,6 +39,6 @@ module ConcurrentRails
40
39
  end
41
40
  end
42
41
 
43
- attr_reader :executor, :task, :future
42
+ attr_reader :executor, :future
44
43
  end
45
44
  end
@@ -5,13 +5,13 @@ module ConcurrentRails
5
5
  include Concurrent::Promises::FactoryMethods
6
6
  extend Forwardable
7
7
 
8
- def self.future(*args, &block)
9
- new.run_on_rails(*args, &block)
8
+ def self.future(*args, &task)
9
+ new.run_on_rails(*args, &task)
10
10
  end
11
11
 
12
- def then(*args, &block)
12
+ def then(*args, &task)
13
13
  @future_instance = Rails.application.executor.wrap do
14
- future_instance.then(*args, &block)
14
+ future_instance.then(*args, &task)
15
15
  end
16
16
 
17
17
  self
@@ -31,9 +31,9 @@ module ConcurrentRails
31
31
  end
32
32
  end
33
33
 
34
- def run_on_rails(*args, &block)
34
+ def run_on_rails(*args, &task)
35
35
  @future_instance = Rails.application.executor.wrap do
36
- future(args, &block)
36
+ future_on(default_executor, *args, &task)
37
37
  end
38
38
 
39
39
  self
@@ -43,6 +43,6 @@ module ConcurrentRails
43
43
 
44
44
  private
45
45
 
46
- attr_reader :task, :future_instance
46
+ attr_reader :future_instance
47
47
  end
48
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ConcurrentRails
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concurrent_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luiz Eduardo Kowalski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails