protocol-redis 0.12.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: 7e63a5453c8130c12c789c00649edc0108ebfba308085df2802f92cec2f43028
4
- data.tar.gz: 8dd7a1c74365983b6e393039493b97c150eb5c188339d7202e72afbeaa1b6e54
3
+ metadata.gz: 13bddcefe812f04cac9130c565ef34dc0c0a31d3de85e510ac13d8191f02a0cc
4
+ data.tar.gz: 78c2898bb6b3c0d7d365eba345758615a2c6d9a7e57ed9cf534819ae5b582eb0
5
5
  SHA512:
6
- metadata.gz: b6856f8a48b5dca486bf09aac258841b4a27a87dcfaa91fdd68a82a3a8040319d018e1d91a7a93a8b804c85dba08f3af301429a03c8b308efa940f08371f34f9
7
- data.tar.gz: 39577c159ef6276b4502c976547453a44477617916d63a5687a62e94d3a6557b31d5d695399d5b7cd5513b6071537f48837a1fdeb35b2a725896ff4be08277a0
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,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
3
6
  module Protocol
4
7
  module Redis
5
8
  module Cluster
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
3
6
  module Protocol
4
7
  module Redis
5
8
  module Cluster
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2025-2026, by Samuel Williams.
5
+
3
6
  module Protocol
4
7
  module Redis
5
8
  module Cluster
@@ -125,12 +128,12 @@ module Protocol
125
128
  def xgroup(*arguments, role: :master)
126
129
  # Extract stream key (usually third argument for CREATE, second for others):
127
130
  stream_key = case arguments[0]&.upcase
128
- when "CREATE", "SETID"
129
- arguments[1] # CREATE stream group id, SETID stream group id
130
- when "DESTROY", "DELCONSUMER"
131
- arguments[1] # DESTROY stream group, DELCONSUMER stream group consumer
132
- else
133
- 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
134
137
  end
135
138
 
136
139
  if stream_key
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
3
6
  module Protocol
4
7
  module Redis
5
8
  module Cluster
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, 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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2023, by Nick Burwell.
5
- # Copyright, 2024, by Samuel Williams.
5
+ # Copyright, 2024-2025, by Samuel Williams.
6
6
 
7
7
  module Protocol
8
8
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
  # Copyright, 2021, by Troex Nevelin.
6
6
 
7
7
  require "date"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
  # Copyright, 2023, by Troex Nevelin.
6
6
  # Copyright, 2023, by Nick Burwell.
7
7
 
@@ -150,9 +150,11 @@ module Protocol
150
150
  # Get all the fields and values in a hash. O(N) where N is the size of the hash.
151
151
  # See <https://redis.io/commands/hgetall> for more details.
152
152
  # @parameter key [Key]
153
- # @returns [Hash]
153
+ # @returns [Hash | Nil]
154
154
  def hgetall(key)
155
- call("HGETALL", key).each_slice(2).to_h
155
+ if pairs = call("HGETALL", key)
156
+ pairs.each_slice(2).to_h
157
+ end
156
158
  end
157
159
 
158
160
  # Iterates fields of Hash types and their associated values. O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
  # Copyright, 2020, by Salim Semaoune.
6
6
 
7
7
  module Protocol
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2023, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2023, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
  # Copyright, 2023, by Nick Burwell.
6
6
 
7
7
  module Protocol
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
  # Copyright, 2020, by David Ortiz.
6
6
 
7
7
  module Protocol
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2023, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2020, by Dimitry Chopey.
5
- # Copyright, 2020-2023, by Samuel Williams.
5
+ # Copyright, 2020-2025, by Samuel Williams.
6
6
 
7
7
  module Protocol
8
8
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2023, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
  # Copyright, 2020, by Dimitry Chopey.
6
6
  # Copyright, 2021, by Daniel Evans.
7
7
  # Copyright, 2023, by Nick Burwell.
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module Redis
8
- VERSION = "0.12.0"
8
+ VERSION = "0.13.1"
9
9
  end
10
10
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  require_relative "redis/version"
7
7
  require_relative "redis/connection"
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2019-2024, 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,14 @@ 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
+
21
+ ### v0.13.0
22
+
23
+ - Handle `nil` return value in `hgetall` method.
24
+
17
25
  ### v0.12.0
18
26
 
19
27
  - Introduce `Pubsub#spublish` method for shard channels.
@@ -53,25 +61,31 @@ Please see the [project releases](https://socketry.github.io/protocol-redis/rele
53
61
 
54
62
  - Add support for multi-argument auth.
55
63
 
56
- ### v0.6.0
57
-
58
- - Add relevant pubsub method group.
59
-
60
- ### v0.5.1
61
-
62
- - Add tests for info command, streams, and string methods.
63
- - Use correct CRLF constant in server methods.
64
- - Modernize gem configuration.
65
-
66
64
  ## Contributing
67
65
 
68
66
  We welcome contributions to this project.
69
67
 
70
- 1. Fork it.
68
+ 1. Fork the repository.
71
69
  2. Create your feature branch (`git checkout -b my-new-feature`).
72
- 3. Commit your changes (`git commit -am 'Add some feature'`).
70
+ 3. Commit your changes (`git commit -am 'Add some feature.'`).
73
71
  4. Push to the branch (`git push origin my-new-feature`).
74
- 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
+ ```
75
89
 
76
90
  ### Developer Certificate of Origin
77
91
 
data/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases
2
2
 
3
+ ## v0.13.1
4
+
5
+ - Close connections when reading a response fails before it is fully consumed.
6
+
7
+ ## v0.13.0
8
+
9
+ - Handle `nil` return value in `hgetall` method.
10
+
3
11
  ## v0.12.0
4
12
 
5
13
  - Introduce `Pubsub#spublish` method for shard channels.
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.12.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