concurrent_rails 0.1.5 → 0.1.6
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 +4 -4
- data/README.md +1 -1
- data/lib/concurrent_rails.rb +2 -2
- data/lib/concurrent_rails/future.rb +2 -6
- data/lib/concurrent_rails/multi.rb +4 -0
- data/lib/concurrent_rails/promises.rb +13 -11
- data/lib/concurrent_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83f0c6f9839dd61c1148dcb02f2a0c4b12d61294af1f7f4f86487f0f0d5f3907
|
4
|
+
data.tar.gz: 2a2a8eddbad74a6a56a6ad7f3b28b46c7c8c1ba7a0c44a30c0a3d0b25496072d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb76a46611d36597321ec8b4fd700a86a844f1f489791005e845c2947893c83652d2675d359ccc628fdc810606ade432e58c1406aa410412e1f80f444a33509
|
7
|
+
data.tar.gz: a5e3a549eb26a86fb9887c3d86ce4aeea71bd604ac8fb42a204b56063d34b7c914f3518bd189fd38a9336f36fc762049905919812eb12d1373cb24139adba76c
|
data/README.md
CHANGED
@@ -143,7 +143,7 @@ For more information on how Futures work and how Rails handle multithread check
|
|
143
143
|
Add this line to your application's Gemfile:
|
144
144
|
|
145
145
|
```ruby
|
146
|
-
gem 'concurrent_rails', '~> 0.1.
|
146
|
+
gem 'concurrent_rails', '~> 0.1.6'
|
147
147
|
```
|
148
148
|
|
149
149
|
And then execute:
|
data/lib/concurrent_rails.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'concurrent_rails/version'
|
4
|
-
require 'concurrent_rails/railtie'
|
5
3
|
require 'concurrent_rails/future'
|
6
4
|
require 'concurrent_rails/multi'
|
7
5
|
require 'concurrent_rails/promises'
|
6
|
+
require 'concurrent_rails/railtie'
|
7
|
+
require 'concurrent_rails/version'
|
8
8
|
|
9
9
|
module ConcurrentRails
|
10
10
|
end
|
@@ -4,7 +4,7 @@ module ConcurrentRails
|
|
4
4
|
class Future
|
5
5
|
extend Forwardable
|
6
6
|
|
7
|
-
def initialize(executor: :
|
7
|
+
def initialize(executor: :fast, &block)
|
8
8
|
@executor = executor
|
9
9
|
@future = run_on_rails(block)
|
10
10
|
end
|
@@ -18,13 +18,9 @@ module ConcurrentRails
|
|
18
18
|
%i[value value!].each do |method_name|
|
19
19
|
define_method method_name do
|
20
20
|
Rails.application.executor.wrap do
|
21
|
-
result = nil
|
22
|
-
|
23
21
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
24
|
-
|
22
|
+
future.__send__(method_name)
|
25
23
|
end
|
26
|
-
|
27
|
-
result
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
@@ -2,11 +2,17 @@
|
|
2
2
|
|
3
3
|
module ConcurrentRails
|
4
4
|
class Promises
|
5
|
-
include Concurrent::Promises::FactoryMethods
|
6
5
|
extend Forwardable
|
6
|
+
include Concurrent::Promises::FactoryMethods
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def future(*args, &task)
|
10
|
+
future_on(:fast, *args, &task)
|
11
|
+
end
|
7
12
|
|
8
|
-
|
9
|
-
|
13
|
+
def future_on(executor, *args, &task)
|
14
|
+
new.with_rails(executor, *args, &task)
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
18
|
def then(*args, &task)
|
@@ -18,22 +24,18 @@ module ConcurrentRails
|
|
18
24
|
end
|
19
25
|
|
20
26
|
%i[value value!].each do |method_name|
|
21
|
-
define_method method_name do
|
27
|
+
define_method method_name do |timeout = nil, timeout_value = nil|
|
22
28
|
Rails.application.executor.wrap do
|
23
|
-
result = nil
|
24
|
-
|
25
29
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
26
|
-
|
30
|
+
future_instance.__send__(method_name, timeout, timeout_value)
|
27
31
|
end
|
28
|
-
|
29
|
-
result
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
def
|
36
|
+
def with_rails(executor, *args, &task)
|
35
37
|
@future_instance = Rails.application.executor.wrap do
|
36
|
-
future_on(
|
38
|
+
future_on(executor, *args, &task)
|
37
39
|
end
|
38
40
|
|
39
41
|
self
|
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.
|
4
|
+
version: 0.1.6
|
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-
|
11
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|