async-io 1.33.0 → 1.34.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75eb7a11c19605c547fda13e17e50f1c18411a3666c05a40c3393de6dd0ec350
4
- data.tar.gz: 89e7ae1d13ecee8609ccffcfc819a209175e306ff647f709ad04879c5aa7e0d3
3
+ metadata.gz: 3791c085eb9bb840e8284d6b480a796412729f34b45835610cab5a26c35db171
4
+ data.tar.gz: 35ce53fb9b6396bd4d233d9ac70df721e8b7abd28db3fcc7a496569bac897623
5
5
  SHA512:
6
- metadata.gz: 31b20b70904328a61be7fd88ee6ed02517cfa2a1a04ef99432ba8f54e1527320892a3302cad90565246e8e409a52ae2fc27a6036001afc23e5696d13dcc6af9f
7
- data.tar.gz: 3520d2320d1fbd1fa584018e85a6d388663d2b27c2e68dd7821e1f6a2a089e349f88c128825c5fd9901a702e97ea3d262c9ffd2a8ed5a5102c6610899c7089c2
6
+ metadata.gz: f9d0bbb019c4dd2d95440efbb2fbb2241d8e62933c167dae1f54a8ae5e2887a1ece25e7186fd1cd030095dc742f460abb2eadc707240a08ace08e373d67811e2
7
+ data.tar.gz: cada614b6a50dceee3aa55350e2cf6fb5af1fa2d6db562892b2e28fcae4ba475c743907dbc5d923cdc9b2eec88a128c89e5221052b9786ec7d3afbd9627567c1
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require_relative 'endpoint'
24
+
25
+ module Async
26
+ module IO
27
+ class CompositeEndpoint < Endpoint
28
+ def initialize(endpoints, **options)
29
+ super(**options)
30
+ @endpoints = endpoints
31
+ end
32
+
33
+ def each(&block)
34
+ @endpoints.each(&block)
35
+ end
36
+
37
+ def connect(&block)
38
+ error = nil
39
+
40
+ @endpoints.each do |endpoint|
41
+ begin
42
+ return endpoint.connect(&block)
43
+ rescue => error
44
+ end
45
+ end
46
+
47
+ raise error
48
+ end
49
+
50
+ def bind(&block)
51
+ @endpoints.map(&:bind)
52
+ end
53
+ end
54
+
55
+ class Endpoint
56
+ def self.composite(*endpoints, **options)
57
+ CompositeEndpoint.new(endpoints, **options)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -98,7 +98,7 @@ module Async
98
98
  end
99
99
  end
100
100
 
101
- wraps ::IO, :external_encoding, :internal_encoding, :autoclose?, :autoclose=, :pid, :stat, :binmode, :flush, :set_encoding, :set_encoding_by_bom, :to_io, :to_i, :reopen, :fileno, :fsync, :fdatasync, :sync, :sync=, :tell, :seek, :rewind, :pos, :pos=, :eof, :eof?, :close_on_exec?, :close_on_exec=, :closed?, :close_read, :close_write, :isatty, :tty?, :binmode?, :sysseek, :advise, :ioctl, :fcntl, :nread, :ready?, :pread, :pwrite, :pathconf
101
+ wraps ::IO, :external_encoding, :internal_encoding, :autoclose?, :autoclose=, :pid, :stat, :binmode, :flush, :set_encoding, :set_encoding_by_bom, :to_path, :to_io, :to_i, :reopen, :fileno, :fsync, :fdatasync, :sync, :sync=, :tell, :seek, :rewind, :path, :pos, :pos=, :eof, :eof?, :close_on_exec?, :close_on_exec=, :closed?, :close_read, :close_write, :isatty, :tty?, :binmode?, :sysseek, :advise, :ioctl, :fcntl, :nread, :ready?, :pread, :pwrite, :pathconf
102
102
 
103
103
  # Read the specified number of bytes from the input stream. This is fast path.
104
104
  # @example
@@ -21,6 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  require_relative 'endpoint'
24
+ require_relative 'composite_endpoint'
24
25
 
25
26
  module Async
26
27
  module IO
@@ -63,6 +64,22 @@ module Async
63
64
  attr :endpoint
64
65
  attr :wrappers
65
66
 
67
+ def local_address_endpoint(**options)
68
+ endpoints = @wrappers.map do |wrapper|
69
+ AddressEndpoint.new(wrapper.to_io.local_address)
70
+ end
71
+
72
+ return CompositeEndpoint.new(endpoints, **options)
73
+ end
74
+
75
+ def remote_address_endpoint(**options)
76
+ endpoints = @wrappers.map do |wrapper|
77
+ AddressEndpoint.new(wrapper.to_io.remote_address)
78
+ end
79
+
80
+ return CompositeEndpoint.new(endpoints, **options)
81
+ end
82
+
66
83
  # Close all the internal wrappers.
67
84
  def close
68
85
  @wrappers.each(&:close)
@@ -57,7 +57,7 @@ module Async
57
57
 
58
58
  alias connect_nonblock connect
59
59
 
60
- # @param duration [Numeric] the maximum time to wait for accepting a connection, if specified.
60
+ # @param timeout [Numeric] the maximum time to wait for accepting a connection, if specified.
61
61
  def accept(timeout: nil, task: Task.current)
62
62
  peer, address = async_send(:accept_nonblock, timeout: timeout)
63
63
  wrapper = Socket.new(peer, task.reactor)
@@ -30,7 +30,7 @@ module Async
30
30
 
31
31
  # Asynchronous TCP socket wrapper.
32
32
  class SSLSocket < Generic
33
- wraps OpenSSL::SSL::SSLSocket, :alpn_protocol, :cert, :cipher, :client_ca, :context, :finished_message, :peer_finished_message, :getsockopt, :hostname, :hostname=, :npn_protocol, :peer_cert, :peer_cert_chain, :pending, :post_connection_check, :setsockopt, :session, :session=, :session_reused?, :ssl_version, :state, :sync_close, :sync_close=, :sysclose, :verify_result, :tmp_key
33
+ wraps OpenSSL::SSL::SSLSocket, :alpn_protocol, :cert, :cipher, :client_ca, :context, :export_keying_material, :finished_message, :peer_finished_message, :getsockopt, :hostname, :hostname=, :npn_protocol, :peer_cert, :peer_cert_chain, :pending, :post_connection_check, :setsockopt, :session, :session=, :session_reused?, :ssl_version, :state, :sync_close, :sync_close=, :sysclose, :verify_result, :tmp_key
34
34
 
35
35
  wrap_blocking_method :accept, :accept_nonblock
36
36
  wrap_blocking_method :connect, :connect_nonblock
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Async
24
24
  module IO
25
- VERSION = "1.33.0"
25
+ VERSION = "1.34.1"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.33.0
4
+ version: 1.34.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2022-03-07 00:00:00.000000000 Z
19
+ date: 2022-12-28 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: async
@@ -127,6 +127,7 @@ files:
127
127
  - lib/async/io/address_endpoint.rb
128
128
  - lib/async/io/binary_string.rb
129
129
  - lib/async/io/buffer.rb
130
+ - lib/async/io/composite_endpoint.rb
130
131
  - lib/async/io/endpoint.rb
131
132
  - lib/async/io/endpoint/each.rb
132
133
  - lib/async/io/generic.rb
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  - !ruby/object:Gem::Version
170
171
  version: '0'
171
172
  requirements: []
172
- rubygems_version: 3.2.32
173
+ rubygems_version: 3.4.1
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: Provides support for asynchonous TCP, UDP, UNIX and SSL sockets.