async-io 1.15.2 → 1.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +16 -0
- data/lib/async/io/ssl_socket.rb +4 -0
- data/lib/async/io/version.rb +1 -1
- data/spec/async/io/shared_endpoint/server_spec.rb +69 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b3e33143cf2ccbc3f24426154313aad72c993a8774a2b6174f5c966bcc19ac4
|
4
|
+
data.tar.gz: c21d6a717368f76a9fd6f03c372b9475ffe8ea0581090ad3b524c0342f486411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 889b395f78a2501ea94ddc1c987b4bb3e7d6bf5220ae0e32a8deb146aede4d49b02a38bcde0a0026a64f6bde7dadf3ef2c34a85c2621126ed1eb840a793b7868
|
7
|
+
data.tar.gz: a73a7d2121f76c413746cd731db704cfcba26745c2493dbd072d973fd3325bc61a1d2a5ffed75f97d1db758a2da6db94933c47072f798dda85f8ba46f94897ee
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -71,6 +71,22 @@ Async::Reactor.run do
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
+
### Timeouts
|
75
|
+
|
76
|
+
Timeouts add a temporal limit to the execution of your code. If the IO doesn't respond in time, it will fail. Timeouts are high level concerns and you generally shouldn't use them except at the very highest level of your program.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
message = task.timeout(5) do
|
80
|
+
begin
|
81
|
+
peer.read(512)
|
82
|
+
rescue Async::TimeoutError
|
83
|
+
nil # The timeout was triggered.
|
84
|
+
end
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
Any `yield` operation can cause a timeout to trigger. Non-`async` functions might not timeout because they are outside the scope of `async`.
|
89
|
+
|
74
90
|
## Contributing
|
75
91
|
|
76
92
|
1. Fork it
|
data/lib/async/io/ssl_socket.rb
CHANGED
data/lib/async/io/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'async/io/ssl_socket'
|
22
|
+
require 'async/rspec/ssl'
|
23
|
+
|
24
|
+
require 'async/io/host_endpoint'
|
25
|
+
require 'async/io/shared_endpoint'
|
26
|
+
|
27
|
+
require 'async/container/forked'
|
28
|
+
require 'async/container/threaded'
|
29
|
+
|
30
|
+
RSpec.shared_examples_for Async::IO::SharedEndpoint do |container_class|
|
31
|
+
include_context Async::RSpec::SSL::VerifiedContexts
|
32
|
+
include_context Async::RSpec::SSL::ValidCertificate
|
33
|
+
|
34
|
+
let(:endpoint) {Async::IO::Endpoint.tcp("127.0.0.1", 6781, reuse_port: true)}
|
35
|
+
let(:server_endpoint) {Async::IO::SecureEndpoint.new(endpoint, ssl_context: server_context)}
|
36
|
+
let(:client_endpoint) {Async::IO::SecureEndpoint.new(endpoint, ssl_context: client_context)}
|
37
|
+
|
38
|
+
let!(:bound_endpoint) do
|
39
|
+
Async::Reactor.run do
|
40
|
+
Async::IO::SharedEndpoint.bound(server_endpoint)
|
41
|
+
end.result
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can use bound endpoint in container" do
|
45
|
+
container = container_class.new(concurrency: 8) do
|
46
|
+
bound_endpoint.accept do |peer|
|
47
|
+
peer.write "Hello World"
|
48
|
+
peer.close
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
Async::Reactor.run do
|
53
|
+
client_endpoint.connect do |peer|
|
54
|
+
expect(peer.read(11)).to eq "Hello World"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
container.stop
|
59
|
+
bound_endpoint.close
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
RSpec.describe Async::Container::Forked do
|
64
|
+
it_behaves_like Async::IO::SharedEndpoint, described_class
|
65
|
+
end
|
66
|
+
|
67
|
+
RSpec.describe Async::Container::Threaded do
|
68
|
+
it_behaves_like Async::IO::SharedEndpoint, described_class
|
69
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.15.
|
4
|
+
version: 1.15.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- spec/async/io/generic_spec.rb
|
135
135
|
- spec/async/io/notification_spec.rb
|
136
136
|
- spec/async/io/protocol/line_spec.rb
|
137
|
+
- spec/async/io/shared_endpoint/server_spec.rb
|
137
138
|
- spec/async/io/shared_endpoint_spec.rb
|
138
139
|
- spec/async/io/socket/tcp_spec.rb
|
139
140
|
- spec/async/io/socket/udp_spec.rb
|
@@ -181,6 +182,7 @@ test_files:
|
|
181
182
|
- spec/async/io/generic_spec.rb
|
182
183
|
- spec/async/io/notification_spec.rb
|
183
184
|
- spec/async/io/protocol/line_spec.rb
|
185
|
+
- spec/async/io/shared_endpoint/server_spec.rb
|
184
186
|
- spec/async/io/shared_endpoint_spec.rb
|
185
187
|
- spec/async/io/socket/tcp_spec.rb
|
186
188
|
- spec/async/io/socket/udp_spec.rb
|