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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19b35ca5f971a4794f10013637f6f01b959e137d8c08e6b6b0696af0c3bd5fbf
4
- data.tar.gz: 8378f92aececdad71c1ea9c8abdc535a4d3ea5942478ce863df362deafde69b7
3
+ metadata.gz: 6b3e33143cf2ccbc3f24426154313aad72c993a8774a2b6174f5c966bcc19ac4
4
+ data.tar.gz: c21d6a717368f76a9fd6f03c372b9475ffe8ea0581090ad3b524c0342f486411
5
5
  SHA512:
6
- metadata.gz: 9ed4c07b72a50e91b1425a7150a3f9a22d88221827e5701e4561b81d1280c8896676a368ed60b04861db3a86ae1583cdb3a9998e6db0b81f3c9f1cbd332dc383
7
- data.tar.gz: b2ffd991b0561986e6e9a3a5bf3d0970f20a90487e43f8f7827ded47713086335446c12ca9ca8c566a1e1197d28fe24b7dbad49ceaaf56ae5d97d17239080d7b
6
+ metadata.gz: 889b395f78a2501ea94ddc1c987b4bb3e7d6bf5220ae0e32a8deb146aede4d49b02a38bcde0a0026a64f6bde7dadf3ef2c34a85c2621126ed1eb840a793b7868
7
+ data.tar.gz: a73a7d2121f76c413746cd731db704cfcba26745c2493dbd072d973fd3325bc61a1d2a5ffed75f97d1db758a2da6db94933c47072f798dda85f8ba46f94897ee
data/Gemfile CHANGED
@@ -17,4 +17,6 @@ group :test do
17
17
 
18
18
  gem 'simplecov'
19
19
  gem 'coveralls', require: false
20
+
21
+ gem 'async-container'
20
22
  end
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
@@ -94,6 +94,10 @@ module Async
94
94
  @context = context
95
95
  end
96
96
 
97
+ def dup
98
+ self.class.new(@server.dup, @context)
99
+ end
100
+
97
101
  def_delegators :@server, :local_address, :setsockopt, :getsockopt, :close, :close_on_exec=, :reactor=
98
102
 
99
103
  attr :server
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module IO
23
- VERSION = "1.15.2"
23
+ VERSION = "1.15.3"
24
24
  end
25
25
  end
@@ -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.2
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-07 00:00:00.000000000 Z
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