exceptional_synchrony 1.2.0 → 1.3.0.pre.1
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/CHANGELOG.md +8 -3
- data/Gemfile +1 -0
- data/Gemfile.lock +39 -35
- data/Rakefile +1 -0
- data/lib/exceptional_synchrony/event_machine_proxy.rb +18 -9
- data/lib/exceptional_synchrony/version.rb +1 -1
- data/test/unit/event_machine_proxy_test.rb +35 -4
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0d8f841987742dd89295a8d2fe15c092fa51e7edab46fa0358ba3ef7951ca198
|
|
4
|
+
data.tar.gz: 7536de648d423a440eb79a8009f587432c0c5a45b9da239f6ed77242ac55484b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1f0806862566cbc09cd589c9bdff8e5b993c173c5c07b297564f2976ab84a25a90942bda76a9fb070fdd3892913de6c8ea997bf847b390651369b603f256b27
|
|
7
|
+
data.tar.gz: 87137e6755580a95ca20d3408335238d03cde525459622b173b46567f21cdb6fc8212fb917504168e96da321075124484557cbc2d706b27ec51f35f4e55f04d2
|
data/CHANGELOG.md
CHANGED
|
@@ -5,10 +5,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
5
5
|
Note: This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
7
|
All notable changes to this project will be documented in this file.
|
|
8
|
-
## [1.1.1] - 2020-05-03
|
|
9
|
-
- Replace hobo_support with invoca_utils
|
|
10
8
|
|
|
11
|
-
[1.
|
|
9
|
+
## [1.3.0] - UNRELEASED
|
|
10
|
+
### Added
|
|
11
|
+
- Extend `EMP.defer` to have a new keyword argument, `wait_for_result` for the callers to control whether they should should block until the background thread returns. To preserve existing behavior, this option defaults to `true`, so `EMP.defer` will block in order to return the value (or raise an exception) from the deferred block. Callers can pass `wait_for_result: false` if they do not want to block.
|
|
12
12
|
|
|
13
13
|
## [1.2.0] - 2020-06-02
|
|
14
14
|
### Changed
|
|
@@ -21,4 +21,9 @@ All notable changes to this project will be documented in this file.
|
|
|
21
21
|
We expect that outer edge handler to log the exception chain (the wrapper plus nested `cause` exception(s))
|
|
22
22
|
and exit the process with a non-0 status code.
|
|
23
23
|
|
|
24
|
+
## [1.1.1] - 2020-05-03
|
|
25
|
+
- Replace hobo_support with invoca_utils
|
|
26
|
+
|
|
27
|
+
[1.3.0]: https://github.com/Invoca/exceptional_synchrony/compare/v1.2.0...v1.3.0
|
|
24
28
|
[1.2.0]: https://github.com/Invoca/exceptional_synchrony/compare/v1.1.1...v1.2.0
|
|
29
|
+
[1.1.1]: https://github.com/Invoca/exceptional_synchrony/compare/v1.1.0...v1.1.1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
exceptional_synchrony (1.
|
|
4
|
+
exceptional_synchrony (1.3.0.pre.1)
|
|
5
5
|
em-http-request
|
|
6
6
|
em-synchrony
|
|
7
7
|
eventmachine
|
|
@@ -11,48 +11,49 @@ PATH
|
|
|
11
11
|
GEM
|
|
12
12
|
remote: https://rubygems.org/
|
|
13
13
|
specs:
|
|
14
|
-
actionmailer (6.
|
|
15
|
-
actionpack (= 6.
|
|
16
|
-
actionview (= 6.
|
|
17
|
-
activejob (= 6.
|
|
14
|
+
actionmailer (6.1.1)
|
|
15
|
+
actionpack (= 6.1.1)
|
|
16
|
+
actionview (= 6.1.1)
|
|
17
|
+
activejob (= 6.1.1)
|
|
18
|
+
activesupport (= 6.1.1)
|
|
18
19
|
mail (~> 2.5, >= 2.5.4)
|
|
19
20
|
rails-dom-testing (~> 2.0)
|
|
20
|
-
actionpack (6.
|
|
21
|
-
actionview (= 6.
|
|
22
|
-
activesupport (= 6.
|
|
23
|
-
rack (~> 2.0, >= 2.0.
|
|
21
|
+
actionpack (6.1.1)
|
|
22
|
+
actionview (= 6.1.1)
|
|
23
|
+
activesupport (= 6.1.1)
|
|
24
|
+
rack (~> 2.0, >= 2.0.9)
|
|
24
25
|
rack-test (>= 0.6.3)
|
|
25
26
|
rails-dom-testing (~> 2.0)
|
|
26
27
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
27
|
-
actionview (6.
|
|
28
|
-
activesupport (= 6.
|
|
28
|
+
actionview (6.1.1)
|
|
29
|
+
activesupport (= 6.1.1)
|
|
29
30
|
builder (~> 3.1)
|
|
30
31
|
erubi (~> 1.4)
|
|
31
32
|
rails-dom-testing (~> 2.0)
|
|
32
33
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
33
|
-
activejob (6.
|
|
34
|
-
activesupport (= 6.
|
|
34
|
+
activejob (6.1.1)
|
|
35
|
+
activesupport (= 6.1.1)
|
|
35
36
|
globalid (>= 0.3.6)
|
|
36
|
-
activesupport (6.
|
|
37
|
+
activesupport (6.1.1)
|
|
37
38
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
38
|
-
i18n (>=
|
|
39
|
-
minitest (
|
|
40
|
-
tzinfo (~>
|
|
41
|
-
zeitwerk (~> 2.
|
|
39
|
+
i18n (>= 1.6, < 2)
|
|
40
|
+
minitest (>= 5.1)
|
|
41
|
+
tzinfo (~> 2.0)
|
|
42
|
+
zeitwerk (~> 2.3)
|
|
42
43
|
addressable (2.7.0)
|
|
43
44
|
public_suffix (>= 2.0.2, < 5.0)
|
|
44
45
|
ansi (1.5.0)
|
|
45
46
|
builder (3.2.4)
|
|
46
47
|
coderay (1.1.2)
|
|
47
|
-
concurrent-ruby (1.1.
|
|
48
|
-
contextual_logger (0.
|
|
48
|
+
concurrent-ruby (1.1.8)
|
|
49
|
+
contextual_logger (0.11.0)
|
|
49
50
|
activesupport
|
|
50
51
|
json
|
|
51
52
|
cookiejar (0.3.3)
|
|
52
53
|
crack (0.4.3)
|
|
53
54
|
safe_yaml (~> 1.0.0)
|
|
54
55
|
crass (1.0.6)
|
|
55
|
-
em-http-request (1.1.
|
|
56
|
+
em-http-request (1.1.7)
|
|
56
57
|
addressable (>= 2.3.4)
|
|
57
58
|
cookiejar (!= 0.3.1)
|
|
58
59
|
em-socksify (>= 0.3)
|
|
@@ -62,9 +63,9 @@ GEM
|
|
|
62
63
|
eventmachine (>= 1.0.0.beta.4)
|
|
63
64
|
em-synchrony (1.0.6)
|
|
64
65
|
eventmachine (>= 1.0.0.beta.1)
|
|
65
|
-
erubi (1.
|
|
66
|
+
erubi (1.10.0)
|
|
66
67
|
eventmachine (1.2.7)
|
|
67
|
-
exception_handling (2.
|
|
68
|
+
exception_handling (2.8.1)
|
|
68
69
|
actionmailer (>= 4.2, < 7.0)
|
|
69
70
|
actionpack (>= 4.2, < 7.0)
|
|
70
71
|
activesupport (>= 4.2, < 7.0)
|
|
@@ -75,31 +76,33 @@ GEM
|
|
|
75
76
|
activesupport (>= 4.2.0)
|
|
76
77
|
hashdiff (1.0.1)
|
|
77
78
|
http_parser.rb (0.6.0)
|
|
78
|
-
i18n (1.8.
|
|
79
|
+
i18n (1.8.7)
|
|
79
80
|
concurrent-ruby (~> 1.0)
|
|
80
|
-
invoca-utils (0.
|
|
81
|
-
json (2.
|
|
82
|
-
loofah (2.
|
|
81
|
+
invoca-utils (0.4.1)
|
|
82
|
+
json (2.5.1)
|
|
83
|
+
loofah (2.9.0)
|
|
83
84
|
crass (~> 1.0.2)
|
|
84
85
|
nokogiri (>= 1.5.9)
|
|
85
86
|
mail (2.7.1)
|
|
86
87
|
mini_mime (>= 0.1.1)
|
|
87
88
|
method_source (1.0.0)
|
|
88
89
|
mini_mime (1.0.2)
|
|
89
|
-
mini_portile2 (2.
|
|
90
|
+
mini_portile2 (2.5.0)
|
|
90
91
|
minitest (5.14.0)
|
|
91
92
|
minitest-reporters (1.4.2)
|
|
92
93
|
ansi
|
|
93
94
|
builder
|
|
94
95
|
minitest (>= 5.0)
|
|
95
96
|
ruby-progressbar
|
|
96
|
-
nokogiri (1.
|
|
97
|
-
mini_portile2 (~> 2.
|
|
97
|
+
nokogiri (1.11.1)
|
|
98
|
+
mini_portile2 (~> 2.5.0)
|
|
99
|
+
racc (~> 1.4)
|
|
98
100
|
pry (0.13.1)
|
|
99
101
|
coderay (~> 1.1)
|
|
100
102
|
method_source (~> 1.0)
|
|
101
103
|
public_suffix (4.0.4)
|
|
102
|
-
|
|
104
|
+
racc (1.5.2)
|
|
105
|
+
rack (2.2.3)
|
|
103
106
|
rack-test (1.1.0)
|
|
104
107
|
rack (>= 1.0, < 3)
|
|
105
108
|
rails-dom-testing (2.0.3)
|
|
@@ -111,15 +114,15 @@ GEM
|
|
|
111
114
|
rr (1.2.1)
|
|
112
115
|
ruby-progressbar (1.10.1)
|
|
113
116
|
safe_yaml (1.0.5)
|
|
117
|
+
test_overrides (1.0.0)
|
|
114
118
|
thor (1.0.1)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
thread_safe (~> 0.1)
|
|
119
|
+
tzinfo (2.0.4)
|
|
120
|
+
concurrent-ruby (~> 1.0)
|
|
118
121
|
webmock (1.24.6)
|
|
119
122
|
addressable (>= 2.3.6)
|
|
120
123
|
crack (>= 0.3.2)
|
|
121
124
|
hashdiff
|
|
122
|
-
zeitwerk (2.
|
|
125
|
+
zeitwerk (2.4.2)
|
|
123
126
|
|
|
124
127
|
PLATFORMS
|
|
125
128
|
ruby
|
|
@@ -131,6 +134,7 @@ DEPENDENCIES
|
|
|
131
134
|
pry
|
|
132
135
|
rake
|
|
133
136
|
rr (~> 1.2)
|
|
137
|
+
test_overrides
|
|
134
138
|
thor
|
|
135
139
|
webmock (~> 1.24)
|
|
136
140
|
|
data/Rakefile
CHANGED
|
@@ -64,6 +64,10 @@ module ExceptionalSynchrony
|
|
|
64
64
|
@proxy_class.next_tick { } #Fake out EventMachine's epoll mechanism so we don't block until timers fire
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
def defers_finished?
|
|
68
|
+
@proxy_class.defers_finished?
|
|
69
|
+
end
|
|
70
|
+
|
|
67
71
|
def connect(server, port = nil, handler = nil, *args, &block)
|
|
68
72
|
@proxy_class.connect(server, port, handler, *args, &block)
|
|
69
73
|
end
|
|
@@ -79,16 +83,21 @@ module ExceptionalSynchrony
|
|
|
79
83
|
end
|
|
80
84
|
end
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
# This method will execute the block on the background thread pool
|
|
87
|
+
# By default, it will block the caller until the background thread has finished, so that the result can be returned
|
|
88
|
+
# :wait_for_result - setting this to false will prevent the caller from being blocked by this deferred work
|
|
89
|
+
def defer(context, wait_for_result: true, &block)
|
|
90
|
+
if wait_for_result
|
|
91
|
+
deferrable = EventMachine::DefaultDeferrable.new
|
|
92
|
+
callback = -> (result) { deferrable.succeed(result) }
|
|
88
93
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
EventMachine.defer(nil, callback) { CallbackExceptions.return_exception(&block) }
|
|
95
|
+
EventMachine::Synchrony.sync(deferrable)
|
|
96
|
+
CallbackExceptions.map_deferred_result(deferrable)
|
|
97
|
+
else
|
|
98
|
+
EventMachine.defer { ExceptionHandling.ensure_completely_safe("defer", &block) }
|
|
99
|
+
nil
|
|
100
|
+
end
|
|
92
101
|
end
|
|
93
102
|
|
|
94
103
|
def reactor_running?
|
|
@@ -24,6 +24,14 @@ describe ExceptionalSynchrony::EventMachineProxy do
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def stop_em_after_defers_finish!(em)
|
|
28
|
+
check_finished_counter = 0
|
|
29
|
+
em.add_periodic_timer(0.1) do
|
|
30
|
+
(check_finished_counter += 1) > 20 and raise "defer never finished!"
|
|
31
|
+
em.defers_finished? and em.stop
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
27
35
|
before do
|
|
28
36
|
@em = ExceptionalSynchrony::EventMachineProxy.new(EventMachine, nil)
|
|
29
37
|
@yielded_value = nil
|
|
@@ -78,18 +86,41 @@ describe ExceptionalSynchrony::EventMachineProxy do
|
|
|
78
86
|
end
|
|
79
87
|
|
|
80
88
|
describe "#defer" do
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
before do
|
|
90
|
+
logger = Logger.new(STDERR)
|
|
91
|
+
logger.extend ContextualLogger::LoggerMixin
|
|
92
|
+
ExceptionHandling.logger = logger
|
|
93
|
+
end
|
|
83
94
|
|
|
95
|
+
it "should output its block's output when it doesn't raise an error, by default" do
|
|
84
96
|
@em.run do
|
|
85
97
|
assert_equal 12, @em.defer("#defer success") { 12 }
|
|
86
98
|
@em.stop
|
|
87
99
|
end
|
|
88
100
|
end
|
|
89
101
|
|
|
90
|
-
it "should
|
|
91
|
-
|
|
102
|
+
it "should not wait for its block to run if option is passed" do
|
|
103
|
+
@block_ran = false
|
|
104
|
+
|
|
105
|
+
@em.run do
|
|
106
|
+
assert_nil @em.defer("#defer success", wait_for_result: false) { @block_ran = true; 12 }
|
|
107
|
+
refute @block_ran
|
|
108
|
+
stop_em_after_defers_finish!(@em)
|
|
109
|
+
end
|
|
92
110
|
|
|
111
|
+
assert @block_ran
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should handle exceptions when not waiting for its block to run" do
|
|
115
|
+
mock(ExceptionHandling).log_error(is_a(RuntimeError), "defer", {})
|
|
116
|
+
|
|
117
|
+
@em.run do
|
|
118
|
+
assert_nil @em.defer("#defer success", wait_for_result: false) { raise RuntimeError, "error in defer" }
|
|
119
|
+
stop_em_after_defers_finish!(@em)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "should raise an error when its block raises an error" do
|
|
93
124
|
@em.run do
|
|
94
125
|
ex = assert_raises(ArgumentError) do
|
|
95
126
|
@em.defer("#defer raising an error") { raise ArgumentError, "!!!" }
|
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: exceptional_synchrony
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0.pre.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Invoca
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2014-01-16 00:00:00.000000000 Z
|
|
@@ -115,7 +115,7 @@ licenses:
|
|
|
115
115
|
metadata:
|
|
116
116
|
source_code_uri: https://github.com/Invoca/exceptional_synchrony
|
|
117
117
|
allowed_push_host: https://rubygems.org
|
|
118
|
-
post_install_message:
|
|
118
|
+
post_install_message:
|
|
119
119
|
rdoc_options: []
|
|
120
120
|
require_paths:
|
|
121
121
|
- lib
|
|
@@ -126,12 +126,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
126
126
|
version: '0'
|
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
|
-
- - "
|
|
129
|
+
- - ">"
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version:
|
|
131
|
+
version: 1.3.1
|
|
132
132
|
requirements: []
|
|
133
133
|
rubygems_version: 3.0.3
|
|
134
|
-
signing_key:
|
|
134
|
+
signing_key:
|
|
135
135
|
specification_version: 4
|
|
136
136
|
summary: Extensions to EventMachine/Synchrony to work well with exceptions
|
|
137
137
|
test_files: []
|