async-io 1.29.0 → 1.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/async/io/host_endpoint.rb +1 -1
  3. data/lib/async/io/trap.rb +4 -3
  4. data/lib/async/io/version.rb +1 -1
  5. metadata +39 -91
  6. data/.editorconfig +0 -6
  7. data/.github/workflows/development.yml +0 -55
  8. data/.gitignore +0 -13
  9. data/.rspec +0 -3
  10. data/.yardopts +0 -2
  11. data/Gemfile +0 -13
  12. data/README.md +0 -171
  13. data/async-io.gemspec +0 -30
  14. data/examples/allocations/byteslice.rb +0 -29
  15. data/examples/allocations/memory.rb +0 -16
  16. data/examples/allocations/read_chunks.rb +0 -18
  17. data/examples/chat/client.rb +0 -58
  18. data/examples/chat/server.rb +0 -83
  19. data/examples/defer/worker.rb +0 -29
  20. data/examples/echo/client.rb +0 -23
  21. data/examples/echo/server.rb +0 -58
  22. data/examples/issues/broken_ssl.rb +0 -15
  23. data/examples/issues/pipes.rb +0 -34
  24. data/examples/millions/client.rb +0 -44
  25. data/examples/millions/server.rb +0 -41
  26. data/examples/udp/client.rb +0 -14
  27. data/examples/udp/server.rb +0 -16
  28. data/gems/nio4r-2.3.gemfile +0 -3
  29. data/spec/addrinfo.rb +0 -16
  30. data/spec/async/io/buffer_spec.rb +0 -48
  31. data/spec/async/io/c10k_spec.rb +0 -138
  32. data/spec/async/io/echo_spec.rb +0 -75
  33. data/spec/async/io/endpoint_spec.rb +0 -105
  34. data/spec/async/io/generic_examples.rb +0 -73
  35. data/spec/async/io/generic_spec.rb +0 -107
  36. data/spec/async/io/notification_spec.rb +0 -46
  37. data/spec/async/io/protocol/line_spec.rb +0 -81
  38. data/spec/async/io/shared_endpoint/server_spec.rb +0 -72
  39. data/spec/async/io/shared_endpoint_spec.rb +0 -65
  40. data/spec/async/io/socket/tcp_spec.rb +0 -101
  41. data/spec/async/io/socket/udp_spec.rb +0 -65
  42. data/spec/async/io/socket_spec.rb +0 -149
  43. data/spec/async/io/ssl_server_spec.rb +0 -133
  44. data/spec/async/io/ssl_socket_spec.rb +0 -96
  45. data/spec/async/io/standard_spec.rb +0 -47
  46. data/spec/async/io/stream_context.rb +0 -30
  47. data/spec/async/io/stream_spec.rb +0 -337
  48. data/spec/async/io/tcp_socket_spec.rb +0 -84
  49. data/spec/async/io/threads_spec.rb +0 -59
  50. data/spec/async/io/trap_spec.rb +0 -52
  51. data/spec/async/io/udp_socket_spec.rb +0 -56
  52. data/spec/async/io/unix_endpoint_spec.rb +0 -106
  53. data/spec/async/io/unix_socket_spec.rb +0 -66
  54. data/spec/async/io/wrap/http_rb_spec.rb +0 -47
  55. data/spec/async/io/wrap/tcp_spec.rb +0 -79
  56. data/spec/spec_helper.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2244383314b8e20f44556404b4615c3ec41215a95fe823b43929e82aee8aa9a0
4
- data.tar.gz: dfd4bb8127fa72430e2155c8b22b69308a2f961f85fcb8230f5fc09c347a3db3
3
+ metadata.gz: 23f8785195920d67cdc0497fd7cbbc4dd261a34722974eff69e49cab8a9bf070
4
+ data.tar.gz: 448e9628835ce82210974bb5c7537785022261e9d5468e5e423b48a11898202f
5
5
  SHA512:
6
- metadata.gz: 2083fe88624d12833af765dd83bd4060a3b7b702d359a3efd08db72cd78f56fe33dbadaf31e98a6980cbcc50164b9557b1a258375d7fa58c9b259ecacf0494aa
7
- data.tar.gz: 4ac435276669ae721afec8b416dc793179467d73794f5f2f34c9276d1db62fc55713a7d4950d92d41bb482674aba051bfd60cddc51f94190a31eee43cfe50222
6
+ metadata.gz: dcbc8e9004a33571775ec58d946d6939ba1a1d9d296a94a1dac4a3d5cce77a2e9bea87154fffe59663f1f59bc8585ee5d3509e77f4257d3dedb7e8372af777d5
7
+ data.tar.gz: c3849305261631553ebbf4a6d2e92fabdbd7ef9d0c6ae94353efd5ad20e4001d4309cc21b1570194aa0a0028e008f6fe6f8f784038adea9f41d6e050494b700c
@@ -77,7 +77,7 @@ module Async
77
77
  # @yield [Socket] the bound socket
78
78
  # @return [Array<Socket>] an array of bound sockets
79
79
  def bind(&block)
80
- Addrinfo.foreach(*@specification).collect do |address|
80
+ Addrinfo.foreach(*@specification).map do |address|
81
81
  Socket.bind(address, **@options, &block)
82
82
  end
83
83
  end
@@ -87,9 +87,10 @@ module Async
87
87
  # Deprecated.
88
88
  alias trap wait
89
89
 
90
- def async(parent: Task.current, &block)
91
- parent.async do |task|
92
- self.trap(task: task, &block)
90
+ # In order to avoid blocking the reactor, specify `transient: true` as an option.
91
+ def async(parent: Task.current, **options, &block)
92
+ parent.async(**options) do |task|
93
+ self.wait(task: task, &block)
93
94
  end
94
95
  end
95
96
 
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Async
24
24
  module IO
25
- VERSION = "1.29.0"
25
+ VERSION = "1.30.0"
26
26
  end
27
27
  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.29.0
4
+ version: 1.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-23 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: async-container
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.15'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: async-rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,21 +53,35 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.10'
41
55
  - !ruby/object:Gem::Dependency
42
- name: async-container
56
+ name: bake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '0.15'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '0.15'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: covered
70
+ name: bake-bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bake-modernize
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - ">="
@@ -81,7 +109,7 @@ dependencies:
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
- name: bake-bundler
112
+ name: covered
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - ">="
@@ -109,35 +137,11 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: '3.0'
111
139
  description:
112
- email:
113
- - samuel.williams@oriontransfer.co.nz
140
+ email:
114
141
  executables: []
115
142
  extensions: []
116
143
  extra_rdoc_files: []
117
144
  files:
118
- - ".editorconfig"
119
- - ".github/workflows/development.yml"
120
- - ".gitignore"
121
- - ".rspec"
122
- - ".yardopts"
123
- - Gemfile
124
- - README.md
125
- - async-io.gemspec
126
- - examples/allocations/byteslice.rb
127
- - examples/allocations/memory.rb
128
- - examples/allocations/read_chunks.rb
129
- - examples/chat/client.rb
130
- - examples/chat/server.rb
131
- - examples/defer/worker.rb
132
- - examples/echo/client.rb
133
- - examples/echo/server.rb
134
- - examples/issues/broken_ssl.rb
135
- - examples/issues/pipes.rb
136
- - examples/millions/client.rb
137
- - examples/millions/server.rb
138
- - examples/udp/client.rb
139
- - examples/udp/server.rb
140
- - gems/nio4r-2.3.gemfile
141
145
  - lib/async/io.rb
142
146
  - lib/async/io/address.rb
143
147
  - lib/async/io/address_endpoint.rb
@@ -166,34 +170,6 @@ files:
166
170
  - lib/async/io/unix_endpoint.rb
167
171
  - lib/async/io/unix_socket.rb
168
172
  - lib/async/io/version.rb
169
- - spec/addrinfo.rb
170
- - spec/async/io/buffer_spec.rb
171
- - spec/async/io/c10k_spec.rb
172
- - spec/async/io/echo_spec.rb
173
- - spec/async/io/endpoint_spec.rb
174
- - spec/async/io/generic_examples.rb
175
- - spec/async/io/generic_spec.rb
176
- - spec/async/io/notification_spec.rb
177
- - spec/async/io/protocol/line_spec.rb
178
- - spec/async/io/shared_endpoint/server_spec.rb
179
- - spec/async/io/shared_endpoint_spec.rb
180
- - spec/async/io/socket/tcp_spec.rb
181
- - spec/async/io/socket/udp_spec.rb
182
- - spec/async/io/socket_spec.rb
183
- - spec/async/io/ssl_server_spec.rb
184
- - spec/async/io/ssl_socket_spec.rb
185
- - spec/async/io/standard_spec.rb
186
- - spec/async/io/stream_context.rb
187
- - spec/async/io/stream_spec.rb
188
- - spec/async/io/tcp_socket_spec.rb
189
- - spec/async/io/threads_spec.rb
190
- - spec/async/io/trap_spec.rb
191
- - spec/async/io/udp_socket_spec.rb
192
- - spec/async/io/unix_endpoint_spec.rb
193
- - spec/async/io/unix_socket_spec.rb
194
- - spec/async/io/wrap/http_rb_spec.rb
195
- - spec/async/io/wrap/tcp_spec.rb
196
- - spec/spec_helper.rb
197
173
  homepage: https://github.com/socketry/async-io
198
174
  licenses:
199
175
  - MIT
@@ -217,32 +193,4 @@ rubygems_version: 3.1.2
217
193
  signing_key:
218
194
  specification_version: 4
219
195
  summary: Provides support for asynchonous TCP, UDP, UNIX and SSL sockets.
220
- test_files:
221
- - spec/addrinfo.rb
222
- - spec/async/io/buffer_spec.rb
223
- - spec/async/io/c10k_spec.rb
224
- - spec/async/io/echo_spec.rb
225
- - spec/async/io/endpoint_spec.rb
226
- - spec/async/io/generic_examples.rb
227
- - spec/async/io/generic_spec.rb
228
- - spec/async/io/notification_spec.rb
229
- - spec/async/io/protocol/line_spec.rb
230
- - spec/async/io/shared_endpoint/server_spec.rb
231
- - spec/async/io/shared_endpoint_spec.rb
232
- - spec/async/io/socket/tcp_spec.rb
233
- - spec/async/io/socket/udp_spec.rb
234
- - spec/async/io/socket_spec.rb
235
- - spec/async/io/ssl_server_spec.rb
236
- - spec/async/io/ssl_socket_spec.rb
237
- - spec/async/io/standard_spec.rb
238
- - spec/async/io/stream_context.rb
239
- - spec/async/io/stream_spec.rb
240
- - spec/async/io/tcp_socket_spec.rb
241
- - spec/async/io/threads_spec.rb
242
- - spec/async/io/trap_spec.rb
243
- - spec/async/io/udp_socket_spec.rb
244
- - spec/async/io/unix_endpoint_spec.rb
245
- - spec/async/io/unix_socket_spec.rb
246
- - spec/async/io/wrap/http_rb_spec.rb
247
- - spec/async/io/wrap/tcp_spec.rb
248
- - spec/spec_helper.rb
196
+ test_files: []
@@ -1,6 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
@@ -1,55 +0,0 @@
1
- name: Development
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ${{matrix.os}}-latest
8
- continue-on-error: ${{matrix.experimental}}
9
-
10
- strategy:
11
- matrix:
12
- os:
13
- - ubuntu
14
- - macos
15
-
16
- ruby:
17
- - 2.5
18
- - 2.6
19
- - 2.7
20
-
21
- experimental: [false]
22
- env: [""]
23
-
24
- include:
25
- - os: ubuntu
26
- ruby: truffleruby
27
- experimental: true
28
- env: JRUBY_OPTS="--debug -X+O"
29
- - os: ubuntu
30
- ruby: jruby
31
- experimental: true
32
- - os: ubuntu
33
- ruby: head
34
- experimental: true
35
- - os: ubuntu
36
- ruby: 2.6
37
- experimental: false
38
- env: COVERAGE=PartialSummary,Coveralls
39
- - os: macos
40
- ruby: 2.7
41
- experimental: false
42
- env: BUNDLE_GEMFILE=gems/nio4r-2.3.gemfile
43
-
44
- steps:
45
- - uses: actions/checkout@v1
46
- - uses: ruby/setup-ruby@v1
47
- with:
48
- ruby-version: ${{matrix.ruby}}
49
-
50
- - name: Install dependencies
51
- run: ${{matrix.env}} bundle install
52
-
53
- - name: Run tests
54
- timeout-minutes: 5
55
- run: ${{matrix.env}} bundle exec rspec
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
- .tags
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- --markup markdown
2
-
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in async-io.gemspec
6
- gemspec
7
-
8
- group :test do
9
- gem 'benchmark-ips'
10
- gem 'ruby-prof', platforms: :mri
11
-
12
- gem 'http'
13
- end
data/README.md DELETED
@@ -1,171 +0,0 @@
1
- # Async::IO
2
-
3
- Async::IO provides builds on [async] and provides asynchronous wrappers for `IO`, `Socket`, and related classes.
4
-
5
- [async]: https://github.com/socketry/async
6
-
7
- [![Actions Status](https://github.com/socketry/async-io/workflows/Development/badge.svg)](https://github.com/socketry/async-io/actions?workflow=Development)
8
- [![Code Climate](https://codeclimate.com/github/socketry/async-io.svg)](https://codeclimate.com/github/socketry/async-io)
9
- [![Coverage Status](https://coveralls.io/repos/socketry/async-io/badge.svg)](https://coveralls.io/r/socketry/async-io)
10
-
11
- ## Installation
12
-
13
- Add this line to your application's Gemfile:
14
-
15
- ```ruby
16
- gem 'async-io'
17
- ```
18
-
19
- And then execute:
20
-
21
- $ bundle
22
-
23
- Or install it yourself as:
24
-
25
- $ gem install async-io
26
-
27
- ## Usage
28
-
29
- Basic echo server (from `spec/async/io/echo_spec.rb`):
30
-
31
- ```ruby
32
- require 'async/io'
33
-
34
- def echo_server(endpoint)
35
- Async do |task|
36
- # This is a synchronous block within the current task:
37
- endpoint.accept do |client|
38
- # This is an asynchronous block within the current reactor:
39
- data = client.read
40
-
41
- # This produces out-of-order responses.
42
- task.sleep(rand * 0.01)
43
-
44
- client.write(data.reverse)
45
- client.close_write
46
- end
47
- end
48
- end
49
-
50
- def echo_client(endpoint, data)
51
- Async do |task|
52
- endpoint.connect do |peer|
53
- peer.write(data)
54
- peer.close_write
55
-
56
- message = peer.read
57
-
58
- puts "Sent #{data}, got response: #{message}"
59
- end
60
- end
61
- end
62
-
63
- Async do
64
- endpoint = Async::IO::Endpoint.tcp('0.0.0.0', 9000)
65
-
66
- server = echo_server(endpoint)
67
-
68
- 5.times.collect do |i|
69
- echo_client(endpoint, "Hello World #{i}")
70
- end.each(&:wait)
71
-
72
- server.stop
73
- end
74
- ```
75
-
76
- ### Timeouts
77
-
78
- 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.
79
-
80
- ```ruby
81
- message = task.with_timeout(5) do
82
- begin
83
- peer.read
84
- rescue Async::TimeoutError
85
- nil # The timeout was triggered.
86
- end
87
- end
88
- ```
89
-
90
- Any `yield` operation can cause a timeout to trigger. Non-`async` functions might not timeout because they are outside the scope of `async`.
91
-
92
- #### Wrapper Timeouts
93
-
94
- Asynchronous operations may block forever. You can assign a per-wrapper operation timeout duration. All asynchronous operations will be bounded by this timeout.
95
-
96
- ```ruby
97
- peer.timeout = 1
98
- peer.read # If this takes more than 1 second, Async::TimeoutError will be raised.
99
- ```
100
-
101
- The benefit of this approach is that it applies to all operations. Typically, this would be configured by the user, and set to something pretty high, e.g. 120 seconds.
102
-
103
- ### Reading Characters
104
-
105
- This example shows how to read one character at a time as the user presses it on the keyboard, and echos it back out as uppercase:
106
-
107
- ```ruby
108
- require 'async'
109
- require 'async/io/stream'
110
- require 'io/console'
111
-
112
- $stdin.raw!
113
- $stdin.echo = false
114
-
115
- Async do |task|
116
- stdin = Async::IO::Stream.new(
117
- Async::IO::Generic.new($stdin)
118
- )
119
-
120
- while character = stdin.read(1)
121
- $stdout.write character.upcase
122
- end
123
- end
124
- ```
125
-
126
- ### Deferred Buffering
127
-
128
- `Async::IO::Stream.new(..., deferred:true)` creates a deferred stream which increases latency slightly, but reduces the number of total packets sent. It does this by combining all calls `Stream#flush` within a single iteration of the reactor. This is typically more useful on the client side, but can also be useful on the server side when individual packets have high latency. It should be preferable to send one 100 byte packet than 10x 10 byte packets.
129
-
130
- Servers typically only deal with one request per iteartion of the reactor so it's less useful. Clients which make multiple requests can benefit significantly e.g. HTTP/2 clients can merge many requests into a single packet. Because HTTP/2 recommends disabling Nagle's algorithm, this is often beneficial.
131
-
132
- ## Contributing
133
-
134
- 1. Fork it
135
- 2. Create your feature branch (`git checkout -b my-new-feature`)
136
- 3. Commit your changes (`git commit -am 'Add some feature'`)
137
- 4. Push to the branch (`git push origin my-new-feature`)
138
- 5. Create new Pull Request
139
-
140
- ## See Also
141
-
142
- - [async](https://github.com/socketry/async) — Asynchronous event-driven reactor.
143
- - [async-process](https://github.com/socketry/async-process) — Asynchronous process spawning/waiting.
144
- - [async-websocket](https://github.com/socketry/async-websocket) — Asynchronous client and server websockets.
145
- - [async-dns](https://github.com/socketry/async-dns) — Asynchronous DNS resolver and server.
146
- - [async-rspec](https://github.com/socketry/async-rspec) — Shared contexts for running async specs.
147
- - [rubydns](https://github.com/ioquatix/rubydns) — A easy to use Ruby DNS server.
148
-
149
- ## License
150
-
151
- Released under the MIT license.
152
-
153
- Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
154
-
155
- Permission is hereby granted, free of charge, to any person obtaining a copy
156
- of this software and associated documentation files (the "Software"), to deal
157
- in the Software without restriction, including without limitation the rights
158
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
159
- copies of the Software, and to permit persons to whom the Software is
160
- furnished to do so, subject to the following conditions:
161
-
162
- The above copyright notice and this permission notice shall be included in
163
- all copies or substantial portions of the Software.
164
-
165
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
166
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
167
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
168
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
169
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
170
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
171
- THE SOFTWARE.