async-io 1.33.0 → 1.34.0
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/lib/async/io/composite_endpoint.rb +61 -0
- data/lib/async/io/shared_endpoint.rb +17 -0
- data/lib/async/io/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0131359c594306a5fbe0e355a33392e6e59608f771677974aa376336ace05e4
|
4
|
+
data.tar.gz: f3e3d7ebd90014cf4692a64cb39e107a95899a64d07536959ec208c45f69044e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 135c73883230c4c902c75b5070bec585fa5849d832eef7e6f1e70df8a456d77c8ebd43869c938ad6b7345b9c05e64f6fd423f53bf93a80cc193453a2d532b981
|
7
|
+
data.tar.gz: 4b6689c582cca834d15d0358a71fd9325ff295ef6477dfd9ec3bf6e5ec84de356c2dee39ad9502fc17c8b76ad3d82d19feef1fb6d4b678eb30d3a2d5076fbd7d
|
@@ -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
|
@@ -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)
|
data/lib/async/io/version.rb
CHANGED
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.
|
4
|
+
version: 1.34.0
|
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-
|
19
|
+
date: 2022-08-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.
|
173
|
+
rubygems_version: 3.3.7
|
173
174
|
signing_key:
|
174
175
|
specification_version: 4
|
175
176
|
summary: Provides support for asynchonous TCP, UDP, UNIX and SSL sockets.
|