io-stream 0.10.0 → 0.11.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
- checksums.yaml.gz.sig +0 -0
- data/lib/io/stream/buffered.rb +14 -7
- data/lib/io/stream/connection_reset_error.rb +7 -0
- data/lib/io/stream/generic.rb +1 -1
- data/lib/io/stream/openssl.rb +1 -1
- data/lib/io/stream/readable.rb +8 -8
- data/lib/io/stream/shim/buffered.rb +1 -1
- data/lib/io/stream/shim/readable.rb +1 -1
- data/lib/io/stream/string_buffer.rb +1 -1
- data/lib/io/stream/version.rb +2 -2
- data/lib/io/stream/writable.rb +1 -1
- data/lib/io/stream.rb +1 -1
- data/readme.md +5 -5
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c071e8e033bc6afd35a809466299187cfbee327acf26787968a7af2baeb89ce
|
4
|
+
data.tar.gz: 748cee4f872237453f35ef91aea936f29a632a27d35cf09235dcdd72b12e5826
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758b8a379a4b745e51a58810011a33fd5473527863da8c655d2f84a8fa135925b258edf25dd2431ab9b4f2b9e983a725cf6855ead510ac832705eb55c08a5d41
|
7
|
+
data.tar.gz: d7acbd5c30572b838503b1e25faea6b6ce046e76581d712bcd2fa6792a3f156992a69610a19d76be6e3746b4782cba479b9e318762dbb5864d5f4ff732fd273e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/io/stream/buffered.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2024, by Samuel Williams.
|
4
|
+
# Copyright, 2024-2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "generic"
|
7
|
+
require_relative "connection_reset_error"
|
7
8
|
|
8
9
|
module IO::Stream
|
9
10
|
# A buffered stream implementation that wraps an underlying IO object to provide efficient buffered reading and writing.
|
@@ -59,34 +60,34 @@ module IO::Stream
|
|
59
60
|
@timeout = nil
|
60
61
|
end
|
61
62
|
end
|
62
|
-
|
63
|
+
|
63
64
|
# @attribute [IO] The wrapped IO object.
|
64
65
|
attr :io
|
65
|
-
|
66
|
+
|
66
67
|
# Get the underlying IO object.
|
67
68
|
# @returns [IO] The underlying IO object.
|
68
69
|
def to_io
|
69
70
|
@io.to_io
|
70
71
|
end
|
71
|
-
|
72
|
+
|
72
73
|
# Check if the stream is closed.
|
73
74
|
# @returns [Boolean] True if the stream is closed.
|
74
75
|
def closed?
|
75
76
|
@io.closed?
|
76
77
|
end
|
77
|
-
|
78
|
+
|
78
79
|
# Close the read end of the stream.
|
79
80
|
def close_read
|
80
81
|
@io.close_read
|
81
82
|
end
|
82
|
-
|
83
|
+
|
83
84
|
# Close the write end of the stream.
|
84
85
|
def close_write
|
85
86
|
super
|
86
87
|
ensure
|
87
88
|
@io.close_write
|
88
89
|
end
|
89
|
-
|
90
|
+
|
90
91
|
# Check if the stream is readable.
|
91
92
|
# @returns [Boolean] True if the stream is readable.
|
92
93
|
def readable?
|
@@ -146,6 +147,12 @@ module IO::Stream
|
|
146
147
|
return result
|
147
148
|
end
|
148
149
|
end
|
150
|
+
rescue OpenSSL::SSL::SSLError => error
|
151
|
+
if error.message =~ /unexpected eof while reading/
|
152
|
+
raise ConnectionResetError, "Connection reset by peer!"
|
153
|
+
end
|
154
|
+
rescue Errno::ECONNRESET
|
155
|
+
raise ConnectionResetError, "Connection reset by peer!"
|
149
156
|
rescue Errno::EBADF
|
150
157
|
raise ::IOError, "stream closed"
|
151
158
|
end
|
data/lib/io/stream/generic.rb
CHANGED
data/lib/io/stream/openssl.rb
CHANGED
data/lib/io/stream/readable.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright,
|
4
|
+
# Copyright, 2025, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative "string_buffer"
|
7
7
|
|
8
8
|
module IO::Stream
|
9
9
|
# The default block size for IO buffers. Defaults to 256KB (optimized for modern SSDs and networks).
|
10
10
|
BLOCK_SIZE = ENV.fetch("IO_STREAM_BLOCK_SIZE", 1024*256).to_i
|
11
|
-
|
11
|
+
|
12
12
|
# The minimum read size for efficient I/O operations. Defaults to the same as BLOCK_SIZE.
|
13
13
|
MINIMUM_READ_SIZE = ENV.fetch("IO_STREAM_MINIMUM_READ_SIZE", BLOCK_SIZE).to_i
|
14
|
-
|
14
|
+
|
15
15
|
# The maximum read size for a single read operation. This limit exists because:
|
16
16
|
# 1. System calls like read() cannot handle requests larger than SSIZE_MAX
|
17
17
|
# 2. Very large reads can cause memory pressure and poor interactive performance
|
@@ -41,21 +41,21 @@ module IO::Stream
|
|
41
41
|
|
42
42
|
super(**, &block) if defined?(super)
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
attr_accessor :minimum_read_size
|
46
|
-
|
46
|
+
|
47
47
|
# Legacy accessor for backwards compatibility
|
48
48
|
# @returns [Integer] The minimum read size.
|
49
49
|
def block_size
|
50
50
|
@minimum_read_size
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
# Legacy setter for backwards compatibility
|
54
54
|
# @parameter value [Integer] The minimum read size.
|
55
55
|
def block_size=(value)
|
56
56
|
@minimum_read_size = value
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
# Read data from the stream.
|
60
60
|
# @parameter size [Integer | Nil] The number of bytes to read. If nil, read until end of stream.
|
61
61
|
# @parameter buffer [String | Nil] An optional buffer to fill with data instead of allocating a new string.
|
@@ -113,7 +113,7 @@ module IO::Stream
|
|
113
113
|
return String.new(encoding: Encoding::BINARY)
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
if !@finished and @read_buffer.empty?
|
118
118
|
fill_read_buffer
|
119
119
|
end
|
data/lib/io/stream/version.rb
CHANGED
data/lib/io/stream/writable.rb
CHANGED
data/lib/io/stream.rb
CHANGED
data/readme.md
CHANGED
@@ -12,6 +12,11 @@ Please see the [project documentation](https://socketry.github.io/io-stream) for
|
|
12
12
|
|
13
13
|
Please see the [project releases](https://socketry.github.io/io-streamreleases/index) for all releases.
|
14
14
|
|
15
|
+
### v0.11.0
|
16
|
+
|
17
|
+
- Introduce `class IO::Stream::ConnectionResetError < Errno::ECONNRESET` to standardize connection reset error handling across different IO types.
|
18
|
+
- `OpenSSL::SSL::SSLSocket` raises `OpenSSL::SSL::SSLError` on connection reset, while other IO types raise `Errno::ECONNRESET`. `SSLError` is now rescued and re-raised as `IO::Stream::ConnectionResetError` for consistency.
|
19
|
+
|
15
20
|
### v0.10.0
|
16
21
|
|
17
22
|
- Rename `done?` to `finished?` for clarity and consistency.
|
@@ -54,11 +59,6 @@ Please see the [project releases](https://socketry.github.io/io-streamreleases/i
|
|
54
59
|
- Ensure TLS connections have correct buffering behavior.
|
55
60
|
- Improve test suite organization and readability.
|
56
61
|
|
57
|
-
### v0.4.2
|
58
|
-
|
59
|
-
- Add external test suite for better integration testing.
|
60
|
-
- Update dependencies and improve code style with RuboCop.
|
61
|
-
|
62
62
|
## See Also
|
63
63
|
|
64
64
|
- [async-io](https://github.com/socketry/async-io) — Where this implementation originally came from.
|
data/releases.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Releases
|
2
2
|
|
3
|
+
## v0.11.0
|
4
|
+
|
5
|
+
- Introduce `class IO::Stream::ConnectionResetError < Errno::ECONNRESET` to standardize connection reset error handling across different IO types.
|
6
|
+
- `OpenSSL::SSL::SSLSocket` raises `OpenSSL::SSL::SSLError` on connection reset, while other IO types raise `Errno::ECONNRESET`. `SSLError` is now rescued and re-raised as `IO::Stream::ConnectionResetError` for consistency.
|
7
|
+
|
3
8
|
## v0.10.0
|
4
9
|
|
5
10
|
- Rename `done?` to `finished?` for clarity and consistency.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -44,6 +44,7 @@ extra_rdoc_files: []
|
|
44
44
|
files:
|
45
45
|
- lib/io/stream.rb
|
46
46
|
- lib/io/stream/buffered.rb
|
47
|
+
- lib/io/stream/connection_reset_error.rb
|
47
48
|
- lib/io/stream/generic.rb
|
48
49
|
- lib/io/stream/openssl.rb
|
49
50
|
- lib/io/stream/readable.rb
|
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '0'
|
77
78
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
+
rubygems_version: 3.7.2
|
79
80
|
specification_version: 4
|
80
81
|
summary: Provides a generic stream wrapper for IO instances.
|
81
82
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|