concurrent_rails 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/concurrent_rails/future.rb +7 -3
- data/lib/concurrent_rails/promises.rb +24 -21
- data/lib/concurrent_rails/version.rb +1 -1
- metadata +2 -3
- data/lib/tasks/concurrent_rails_tasks.rake +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 257bcdcbd99076d7b73c193297ce5bc410c1fd5962bb823b965b5abbdf21197c
|
4
|
+
data.tar.gz: 5ae2230ba4416193fac70bcd9500673e7d96081491786717eb8d6ce95c938f92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df4405c6f8e8efe155dea24db8a3799955b59c4d3a93118153b557711941c66428027caea64d245df4437be49d3d0482ffb2461bad863b38877e152f57eb6970
|
7
|
+
data.tar.gz: 8c11ffcd0afbeedf533a8da19ca19f79a1e2566e326946f55e699337f45c179a2f245f5b4fd46f62b694a9803ac317cf0bfb6dec95c38285cf3487c5631a4457
|
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.8'
|
147
147
|
```
|
148
148
|
|
149
149
|
And then execute:
|
@@ -17,7 +17,7 @@ module ConcurrentRails
|
|
17
17
|
|
18
18
|
%i[value value!].each do |method_name|
|
19
19
|
define_method method_name do
|
20
|
-
|
20
|
+
rails_wrapped do
|
21
21
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
22
22
|
future.__send__(method_name)
|
23
23
|
end
|
@@ -30,13 +30,17 @@ module ConcurrentRails
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def run_on_rails(block)
|
33
|
-
@future =
|
33
|
+
@future = rails_wrapped do
|
34
34
|
Concurrent::Future.new(executor: executor) do
|
35
|
-
|
35
|
+
rails_wrapped(&block)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def rails_wrapped(&block)
|
41
|
+
Rails.application.executor.wrap(&block)
|
42
|
+
end
|
43
|
+
|
40
44
|
attr_reader :executor, :future
|
41
45
|
end
|
42
46
|
end
|
@@ -11,29 +11,34 @@ module ConcurrentRails
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def future_on(executor, *args, &task)
|
14
|
-
new.
|
14
|
+
new(executor).run_on_rails(*args, &task)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
@
|
20
|
-
|
21
|
-
|
18
|
+
def initialize(executor)
|
19
|
+
@executor = executor
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_on_rails(*args, &task)
|
23
|
+
@future_instance = rails_wrapped { future_on(executor, *args, &task) }
|
22
24
|
|
23
25
|
self
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
%i[then chain].each do |chainable|
|
29
|
+
define_method(chainable) do |*args, &task|
|
30
|
+
method = "#{chainable}_on"
|
31
|
+
@future_instance = rails_wrapped do
|
32
|
+
future_instance.__send__(method, executor, *args, &task)
|
33
|
+
end
|
30
34
|
|
31
|
-
|
35
|
+
self
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
%i[value value!].each do |method_name|
|
35
|
-
define_method
|
36
|
-
|
40
|
+
define_method(method_name) do |timeout = nil, timeout_value = nil|
|
41
|
+
rails_wrapped do
|
37
42
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
38
43
|
future_instance.__send__(method_name, timeout, timeout_value)
|
39
44
|
end
|
@@ -41,18 +46,16 @@ module ConcurrentRails
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
future_on(executor, *args, &task)
|
47
|
-
end
|
48
|
-
|
49
|
-
self
|
49
|
+
%i[state reason rejected? resolved? fulfilled?].each do |delegatable|
|
50
|
+
def_delegator :@future_instance, delegatable
|
50
51
|
end
|
51
52
|
|
52
|
-
def_delegators :@future_instance, :state, :reason, :rejected?, :resolved?
|
53
|
-
|
54
53
|
private
|
55
54
|
|
56
|
-
|
55
|
+
def rails_wrapped(&block)
|
56
|
+
Rails.application.executor.wrap(&block)
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_reader :future_instance, :executor
|
57
60
|
end
|
58
61
|
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.
|
4
|
+
version: 0.1.8
|
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-05-
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- lib/concurrent_rails/promises.rb
|
69
69
|
- lib/concurrent_rails/railtie.rb
|
70
70
|
- lib/concurrent_rails/version.rb
|
71
|
-
- lib/tasks/concurrent_rails_tasks.rake
|
72
71
|
homepage: https://github.com/luizkowalski/concurrent_rails
|
73
72
|
licenses:
|
74
73
|
- MIT
|