valkey-glide-rb 1.1.0.pre.rc2 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfc81a09f2d8b032a39e6f0262847803a676610d16ea6f61dd0394e69c715b2c
4
- data.tar.gz: 6737025091639c50123942649e2cd96bf47e702b3949eb1352e566e88be09487
3
+ metadata.gz: e8a9f85a697b42fa02cb8f2c6a3734f980a3fd3739f1b57ec393dab473489827
4
+ data.tar.gz: e738ae239e2bc9f40cbee76fd2fc4e88c6b770ceb70fe64d1eda1293ef0f5363
5
5
  SHA512:
6
- metadata.gz: 181f412f7a9836b5bcb766ca9948828b25ca170b19ae9b60a398a4345f90e0bc6f5f6a5feb81f37b0da9cd81ad6d817770af67e794867e7f92e067753c1e43b8
7
- data.tar.gz: 0ee99333bb440ea2fe407dac753eda7c69228eb21097493917974495729e523e883edc6305edb42604cad17e3a90948608302ba8394ec64d69e8b20d2e547f68
6
+ metadata.gz: 20416438b395e699f446765dd7f071c79a2e7bb58e7d3a30a53182d4e47941a91ff09ddeadb14b8e06c5734c159d258caa101d079cc12d2f1c556c242bb9444a
7
+ data.tar.gz: 89fbdd10812cf78d6a8c3a23ed7db215e5a3d07c5602eff8b022d5308f8a55087cf84b13e9471f6da6d69c6bd6b167e4041b629e1b099a336e17ec174ddca831
data/CHANGELOG.md CHANGED
@@ -38,6 +38,7 @@ GLIDE Ruby follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
38
38
 
39
39
  ### Changed
40
40
 
41
+ - Changed `publish` to accept positional arguments as `publish(channel, message, sharded: false)`, matching redis-rb. ([#432](https://github.com/valkey-io/valkey-glide-ruby/pull/432))
41
42
  - Prevented `client(:subcommand)` from invoking private methods, so custom `Valkey` subclasses must make any dispatched `client_*` handlers public. ([#246](https://github.com/valkey-io/valkey-glide-ruby/pull/246))
42
43
  - Trimmed whitespace from string `client_az` values and rejected blank values when an availability-zone affinity strategy is selected. ([#349](https://github.com/valkey-io/valkey-glide-ruby/pull/349))
43
44
  - Changed `eval`, `evalsha`, their read-only variants, and `script_load` to execute server commands, accept integer key counts, and report missing scripts instead of reloading them automatically. ([#227](https://github.com/valkey-io/valkey-glide-ruby/pull/227))
@@ -49,6 +50,7 @@ GLIDE Ruby follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
49
50
 
50
51
  ### Fixed
51
52
 
53
+ - Stopped echoing `ssl_params` values, including private keys, in connection errors, and accepted PEM text for `ca_file`, `cert`, and `key`. ([#428](https://github.com/valkey-io/valkey-glide-ruby/pull/428))
52
54
  - Required TLS for IAM authentication, rejecting IAM configurations without TLS during client creation. ([#397](https://github.com/valkey-io/valkey-glide-ruby/pull/397))
53
55
  - Rejected `cluster_mode: true` without an explicit seed node instead of connecting to the standalone default. ([#344](https://github.com/valkey-io/valkey-glide-ruby/pull/344))
54
56
  - Treated empty `lib_name:` and `client_info_tag:` values as unset so they no longer produce invalid library names. ([#246](https://github.com/valkey-io/valkey-glide-ruby/pull/246))
data/README.md CHANGED
@@ -110,7 +110,7 @@ client.get("foo")
110
110
  | `timeout` | Request timeout in seconds (default `5.0`) |
111
111
  | `connect_timeout` | Connection timeout in seconds |
112
112
  | `ssl`| Enable TLS if true |
113
- | `ssl_params` | TLS options {`ca_file`, `cert`, `key`, `ca_path`, `root_certs`} |
113
+ | `ssl_params` | TLS options {`ca_file`, `cert`, `key`, `ca_path`, `root_certs`}. `ca_file`, `cert` and `key` each accept a file path, PEM text, or an OpenSSL object. |
114
114
  | `cluster_mode` | Enable cluster client |
115
115
  | `nodes` | Array of `{ host:, port: }` hashes |
116
116
  | `protocol` | `:resp3` (default) or `:resp2`|
@@ -334,17 +334,17 @@ class Valkey
334
334
  #
335
335
  # This method aggregates the PUBLISH and SPUBLISH functionalities; the mode is selected with the
336
336
  # `sharded` parameter. In both modes the request is routed using the hashed channel as key. The
337
- # argument order is `(message, channel)`, matching the other GLIDE clients.
337
+ # argument order is `(channel, message)`, matching redis-rb.
338
338
  #
339
339
  # @example Publish a message
340
- # valkey.publish("Hello, World!", "channel1")
340
+ # valkey.publish("channel1", "Hello, World!")
341
341
  # # => 2
342
342
  # @example Publish on a sharded channel
343
- # valkey.publish("Hello, Shard!", "shard1", sharded: true)
343
+ # valkey.publish("shard1", "Hello, Shard!", sharded: true)
344
344
  # # => 1
345
345
  #
346
- # @param [String] message - the message to publish
347
346
  # @param [String] channel - the channel to publish the message on
347
+ # @param [String] message - the message to publish
348
348
  # @param [Boolean] sharded - use sharded Pub/Sub mode; only available in cluster mode
349
349
  # (`cluster_mode: true`). Since: Valkey version 7.0.0
350
350
  #
@@ -354,7 +354,7 @@ class Valkey
354
354
  #
355
355
  # @see https://valkey.io/commands/publish/
356
356
  # @see https://valkey.io/commands/spublish/
357
- def publish(message, channel, sharded: false)
357
+ def publish(channel, message, sharded: false)
358
358
  request_type = sharded ? RequestType::SPUBLISH : RequestType::PUBLISH
359
359
  send_command(request_type, [channel.to_s, message.to_s])
360
360
  end
@@ -188,7 +188,7 @@ class Valkey
188
188
  # rubocop:enable Lint/UselessMethodDefinition
189
189
 
190
190
  # Mirror Python sync which only allow sharded Pub/Sub in ClusterBatch.
191
- def publish(message, channel, sharded: false)
191
+ def publish(channel, message, sharded: false)
192
192
  raise ArgumentError, "publish with sharded: true is only available in cluster mode." if sharded && !cluster_mode?
193
193
 
194
194
  super
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Valkey
4
- VERSION = "1.1.0-rc2"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/valkey.rb CHANGED
@@ -293,13 +293,13 @@ class Valkey
293
293
  # TLS/SSL certificates
294
294
  root_certs = []
295
295
  if options[:ssl_params].is_a?(Hash)
296
- # ca_file - CA certificate file path
296
+ # ca_file - CA certificate file path, PEM text or OpenSSL::X509::Certificate
297
297
  root_certs << read_ssl_value(options[:ssl_params][:ca_file], "CA") if options[:ssl_params][:ca_file]
298
298
 
299
299
  # Additional root certificates from ca_path
300
300
  if options[:ssl_params][:ca_path]
301
301
  ca_path = options[:ssl_params][:ca_path]
302
- raise ArgumentError, "CA path does not exist: #{ca_path}" unless Dir.exist?(ca_path)
302
+ raise ArgumentError, "CA path does not exist (pass a directory path)" unless Dir.exist?(ca_path)
303
303
 
304
304
  Dir.glob(File.join(ca_path, "*.crt")).each do |cert_file|
305
305
  root_certs << File.binread(cert_file) if File.readable?(cert_file)
@@ -309,10 +309,10 @@ class Valkey
309
309
  end
310
310
  end
311
311
 
312
- # cert - file path or OpenSSL::X509::Certificate
312
+ # cert - file path, PEM text or OpenSSL::X509::Certificate
313
313
  json_options["client_cert"] = read_ssl_value(options[:ssl_params][:cert], "Cert") if options[:ssl_params][:cert]
314
314
 
315
- # key - file path or OpenSSL::PKey
315
+ # key - file path, PEM text or OpenSSL::PKey
316
316
  json_options["client_key"] = read_ssl_value(options[:ssl_params][:key], "Key") if options[:ssl_params][:key]
317
317
 
318
318
  # Direct root_certs array support
@@ -663,14 +663,23 @@ class Valkey
663
663
  conn
664
664
  end
665
665
 
666
- # Read an SSL value
667
- # Accepts a file path (String), an OpenSSL object (#to_pem / #to_der), or a fallback #to_s.
666
+ # Resolves an `ssl_params` `ca_file`, `cert` or `key` value to certificate or key content.
667
+ # Accepts PEM text (a String containing `-----BEGIN `), a file path (any other String),
668
+ # an OpenSSL object (#to_pem / #to_der), or a fallback #to_s.
669
+ # Error messages never include the value: it may be a private key.
668
670
  def read_ssl_value(value, label)
669
671
  if value.is_a?(String)
670
- raise ArgumentError, "#{label} file does not exist: #{value}" unless File.exist?(value)
671
- raise ArgumentError, "#{label} file is not readable: #{value}" unless File.readable?(value)
672
+ return value if value.include?("-----BEGIN ")
672
673
 
673
- File.binread(value)
674
+ expected = "(pass a file path, PEM text, or an OpenSSL object)"
675
+ raise ArgumentError, "#{label} file does not exist #{expected}" unless File.exist?(value)
676
+ raise ArgumentError, "#{label} file is not readable #{expected}" unless File.readable?(value)
677
+
678
+ begin
679
+ File.binread(value)
680
+ rescue SystemCallError, IOError
681
+ raise ArgumentError, "#{label} file could not be read #{expected}", cause: nil
682
+ end
674
683
  # Duck-typing check
675
684
  elsif value.respond_to?(:to_pem)
676
685
  value.to_pem
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valkey-glide-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.pre.rc2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valkey GLIDE Maintainers