protocol-redis 0.13.0 → 0.13.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: 7ab24c3be78570c64568f0edbad8fd32ff280497aaa55dbd4c42e1fa4982d5be
4
- data.tar.gz: 7616933dde922356fe3876eb842faeee6d771a78c868b1ae2b5b4b63fd223d35
3
+ metadata.gz: 13bddcefe812f04cac9130c565ef34dc0c0a31d3de85e510ac13d8191f02a0cc
4
+ data.tar.gz: 78c2898bb6b3c0d7d365eba345758615a2c6d9a7e57ed9cf534819ae5b582eb0
5
5
  SHA512:
6
- metadata.gz: bd118bb6882be321a74a24f6e320b0fa01aaa38946d90552cc3058c38c9b02d3bf393fc6d6f3577f38c7f4e69b598b7769e3de3220a48aca62abc272ea93677c
7
- data.tar.gz: 7a0225e6dcee718263a8730fd8db3f08ac6f05ee93be724928f6abf86ff820859da2dfcc699fb6d89611713ff262917ae608ab49a4df68bbace8a4fe95402f74
6
+ metadata.gz: 1d373f1fb921e78847f90aebd248e864919a0d5dde74c293d809358f13371cd789352fcf72e0d2b97faedc3799d283262d410658fca5551f28664c2f3d27b918
7
+ data.tar.gz: d616c4c2a988c0e4416ae9760d5b8b2497aaeb4c63c3b34c2ea6e33144cf714fb251cc066db2065f20aebbd6aa1865f8a69cc14a57f1b933f0ea552063c68bce
checksums.yaml.gz.sig CHANGED
Binary file
data/context/index.yaml CHANGED
@@ -3,6 +3,8 @@
3
3
  ---
4
4
  description: A transport agnostic RESP protocol client/server.
5
5
  metadata:
6
+ bug_tracker_uri: https://github.com/socketry/protocol-redis/issues
7
+ changelog_uri: https://github.com/socketry/protocol-redis/blob/main/releases.md
6
8
  documentation_uri: https://socketry.github.io/protocol-redis/
7
9
  funding_uri: https://github.com/sponsors/ioquatix
8
10
  source_code_uri: https://github.com/socketry/protocol-redis.git
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2025, by Samuel Williams.
4
+ # Copyright, 2025-2026, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -128,12 +128,12 @@ module Protocol
128
128
  def xgroup(*arguments, role: :master)
129
129
  # Extract stream key (usually third argument for CREATE, second for others):
130
130
  stream_key = case arguments[0]&.upcase
131
- when "CREATE", "SETID"
132
- arguments[1] # CREATE stream group id, SETID stream group id
133
- when "DESTROY", "DELCONSUMER"
134
- arguments[1] # DESTROY stream group, DELCONSUMER stream group consumer
135
- else
136
- arguments[1] if arguments.length > 1
131
+ when "CREATE", "SETID"
132
+ arguments[1] # CREATE stream group id, SETID stream group id
133
+ when "DESTROY", "DELCONSUMER"
134
+ arguments[1] # DESTROY stream group, DELCONSUMER stream group consumer
135
+ else
136
+ arguments[1] if arguments.length > 1
137
137
  end
138
138
 
139
139
  if stream_key
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2025, by Samuel Williams.
4
+ # Copyright, 2019-2026, by Samuel Williams.
5
5
 
6
6
  require_relative "error"
7
7
 
@@ -103,8 +103,12 @@ module Protocol
103
103
  # @raises [ServerError] If the server returns an error response.
104
104
  # @raises [EOFError] If the stream reaches end of file.
105
105
  def read_object
106
- line = read_line or raise EOFError
106
+ # Whether the current response was fully consumed:
107
+ complete = false
108
+ object = nil
107
109
 
110
+ # The line that we are processing:
111
+ line = read_line or raise EOFError
108
112
  token = line.slice!(0, 1)
109
113
 
110
114
  case token
@@ -112,35 +116,40 @@ module Protocol
112
116
  length = line.to_i
113
117
 
114
118
  if length == -1
115
- return nil
119
+ # No data.
116
120
  else
117
- return read_data(length)
121
+ object = read_data(length)
118
122
  end
123
+
124
+ complete = true
119
125
  when "*"
120
126
  count = line.to_i
121
127
 
122
- # Null array (https://redis.io/topics/protocol#resp-arrays):
123
- return nil if count == -1
124
-
125
- array = Array.new(count) {read_object}
128
+ if count == -1
129
+ # Null array (https://redis.io/topics/protocol#resp-arrays).
130
+ else
131
+ object = Array.new(count){read_object}
132
+ end
126
133
 
127
- return array
134
+ complete = true
128
135
  when ":"
129
- return line.to_i
130
-
136
+ object = line.to_i
137
+ complete = true
131
138
  when "-"
139
+ complete = true
132
140
  raise ServerError.new(line)
133
-
134
141
  when "+"
135
- return line
136
-
142
+ object = line
143
+ complete = true
137
144
  else
138
145
  @stream.flush
139
146
 
140
147
  raise UnknownTokenError, token.inspect
141
148
  end
142
149
 
143
- # TODO: If an exception (e.g. Async::TimeoutError) propagates out of this function, perhaps @stream should be closed? Otherwise it might be in a weird state.
150
+ return object
151
+ ensure
152
+ close unless complete
144
153
  end
145
154
 
146
155
  alias read_response read_object
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Redis
8
- VERSION = "0.13.0"
8
+ VERSION = "0.13.1"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2019-2025, by Samuel Williams.
3
+ Copyright, 2019-2026, by Samuel Williams.
4
4
  Copyright, 2020, by Olle Jonsson.
5
5
  Copyright, 2020, by Salim Semaoune.
6
6
  Copyright, 2020, by Dimitry Chopey.
data/readme.md CHANGED
@@ -14,6 +14,10 @@ Please see the [project documentation](https://socketry.github.io/protocol-redis
14
14
 
15
15
  Please see the [project releases](https://socketry.github.io/protocol-redis/releases/index) for all releases.
16
16
 
17
+ ### v0.13.1
18
+
19
+ - Close connections when reading a response fails before it is fully consumed.
20
+
17
21
  ### v0.13.0
18
22
 
19
23
  - Handle `nil` return value in `hgetall` method.
@@ -57,19 +61,31 @@ Please see the [project releases](https://socketry.github.io/protocol-redis/rele
57
61
 
58
62
  - Add support for multi-argument auth.
59
63
 
60
- ### v0.6.0
61
-
62
- - Add relevant pubsub method group.
63
-
64
64
  ## Contributing
65
65
 
66
66
  We welcome contributions to this project.
67
67
 
68
- 1. Fork it.
68
+ 1. Fork the repository.
69
69
  2. Create your feature branch (`git checkout -b my-new-feature`).
70
- 3. Commit your changes (`git commit -am 'Add some feature'`).
70
+ 3. Commit your changes (`git commit -am 'Add some feature.'`).
71
71
  4. Push to the branch (`git push origin my-new-feature`).
72
- 5. Create new Pull Request.
72
+ 5. Create a new pull request.
73
+
74
+ ### Running Tests
75
+
76
+ To run the test suite:
77
+
78
+ ``` bash
79
+ $ bundle exec sus
80
+ ```
81
+
82
+ ### Making Releases
83
+
84
+ To make a new release:
85
+
86
+ ``` bash
87
+ $ bundle exec bake gem:release:patch # or minor or major
88
+ ```
73
89
 
74
90
  ### Developer Certificate of Origin
75
91
 
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.13.1
4
+
5
+ - Close connections when reading a response fails before it is fully consumed.
6
+
3
7
  ## v0.13.0
4
8
 
5
9
  - Handle `nil` return value in `hgetall` method.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -84,6 +84,8 @@ homepage: https://github.com/socketry/protocol-redis
84
84
  licenses:
85
85
  - MIT
86
86
  metadata:
87
+ bug_tracker_uri: https://github.com/socketry/protocol-redis/issues
88
+ changelog_uri: https://github.com/socketry/protocol-redis/blob/main/releases.md
87
89
  documentation_uri: https://socketry.github.io/protocol-redis/
88
90
  funding_uri: https://github.com/sponsors/ioquatix
89
91
  source_code_uri: https://github.com/socketry/protocol-redis.git
@@ -94,14 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
96
  requirements:
95
97
  - - ">="
96
98
  - !ruby/object:Gem::Version
97
- version: '3.2'
99
+ version: '3.3'
98
100
  required_rubygems_version: !ruby/object:Gem::Requirement
99
101
  requirements:
100
102
  - - ">="
101
103
  - !ruby/object:Gem::Version
102
104
  version: '0'
103
105
  requirements: []
104
- rubygems_version: 3.6.9
106
+ rubygems_version: 4.0.10
105
107
  specification_version: 4
106
108
  summary: A transport agnostic RESP protocol client/server.
107
109
  test_files: []
metadata.gz.sig CHANGED
Binary file