redis-client 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa81349f7f830db128f2637bc4c782543b9c51a16075b54fdc4700810a95ae83
4
- data.tar.gz: d34e19d6229292bb6b15e61aebeda57729780040e098f0fae1beb534f9717ff9
3
+ metadata.gz: 35ff65a4af6127cb60acff6a3d3b2d2e5e65ddeffc0e8e808b7dec90792697a6
4
+ data.tar.gz: 854f82d7548c5462b53ae29a637dc208cdc70b3399b28d0c61f38e02f073e37e
5
5
  SHA512:
6
- metadata.gz: 01ed887cfc90ffc36ff82669a459d1c9b13b72c9d81f66ca770e7642c16cba90d30cfd31768029b81a1519778f6af2905b145ab606f070008ac471192ce812fa
7
- data.tar.gz: 64320bfdcdaa3fd4402ae41350dc0451127f895e3f224d916140ea3fc5813dfe9344f04dc18c20d82e9c3a0878d19ade9b3716274278a21fbe3fd1c5da855797
6
+ metadata.gz: 2c9e8e564662e86f4e1a24ca9528a5d909a096218eaf62bd7b58838402db390e7bec65d79a43aa89a2b98d22f9645ca7e412ae2db4010dc4131cbf2133d2666f
7
+ data.tar.gz: c6400693a10e28e377bf52792ee54f41afb2b2c97ea49578a90eba767b6e3b6a7f37eaeaccf41a38a8222827f461f44aa0b1f75881084dc30a521e407508e277
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.16.0
4
+
5
+ - Add `RedisClient#disable_reconnection`.
6
+ - Reverted the special discard of connection. A regular `close(2)` should be enough.
7
+
3
8
  # 0.15.0
4
9
 
5
10
  - Discard sockets rather than explictly close them when a fork is detected. #126.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.15.0)
4
+ redis-client (0.16.0)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -19,7 +19,7 @@ GEM
19
19
  ast (~> 2.4.1)
20
20
  rainbow (3.1.1)
21
21
  rake (13.0.6)
22
- rake-compiler (1.2.3)
22
+ rake-compiler (1.2.5)
23
23
  rake
24
24
  redis (4.6.0)
25
25
  regexp_parser (2.5.0)
data/README.md CHANGED
@@ -42,7 +42,7 @@ redis.with do |r|
42
42
  end
43
43
  ```
44
44
 
45
- If you are working in a single threaded environment, or wish to use your own connection pooling mechanism,
45
+ If you are working in a single-threaded environment, or wish to use your own connection pooling mechanism,
46
46
  you can obtain a raw client with `#new_client`
47
47
 
48
48
  ```ruby
@@ -67,11 +67,11 @@ redis.call("GET", "mykey")
67
67
  - `host`: The server hostname or IP address. Defaults to `"localhost"`.
68
68
  - `port`: The server port. Defaults to `6379`.
69
69
  - `path`: The path to a UNIX socket, if set `url`, `host` and `port` are ignored.
70
- - `ssl`: Wether to connect using SSL or not.
70
+ - `ssl`: Whether to connect using SSL or not.
71
71
  - `ssl_params`: A configuration Hash passed to [`OpenSSL::SSL::SSLContext#set_params`](https://www.rubydoc.info/stdlib/openssl/OpenSSL%2FSSL%2FSSLContext:set_params), notable options include:
72
72
  - `cert`: The path to the client certificate (e.g. `client.crt`).
73
73
  - `key`: The path to the client key (e.g. `client.key`).
74
- - `ca_file`: The certificate authority to use, useful for self signed certificates (e.g. `ca.crt`),
74
+ - `ca_file`: The certificate authority to use, useful for self-signed certificates (e.g. `ca.crt`),
75
75
  - `db`: The database to select after connecting, defaults to `0`.
76
76
  - `id` ID for the client connection, assigns name to current connection by sending `CLIENT SETNAME`.
77
77
  - `username` Username to authenticate against server, defaults to `"default"`.
@@ -83,7 +83,7 @@ redis.call("GET", "mykey")
83
83
  - `reconnect_attempts`: Specify how many times the client should retry to send queries. Defaults to `0`. Makes sure to read the [reconnection section](#reconnection) before enabling it.
84
84
  - `circuit_breaker`: A Hash with circuit breaker configuration. Defaults to `nil`. See the [circuit breaker section](#circuit-breaker) for details.
85
85
  - `protocol:` The version of the RESP protocol to use. Default to `3`.
86
- - `custom`: A user owned value ignored by `redis-client` but available as `Config#custom`. This can be used to hold middleware configurations and other user specific metadatas.
86
+ - `custom`: A user-owned value ignored by `redis-client` but available as `Config#custom`. This can be used to hold middleware configurations and other user-specific metadata.
87
87
 
88
88
  ### Sentinel support
89
89
 
@@ -344,7 +344,7 @@ end
344
344
  ```
345
345
 
346
346
  *Note*: pubsub connections are stateful, as such they won't ever reconnect automatically.
347
- The caller is resonsible for reconnecting if the connection is lost and to resubscribe to
347
+ The caller is responsible for reconnecting if the connection is lost and to resubscribe to
348
348
  all channels.
349
349
 
350
350
  ## Production
@@ -380,7 +380,7 @@ redis_config = RedisClient.config(middlewares: [AnotherRedisInstrumentation])
380
380
  redis_config.new_client
381
381
  ```
382
382
 
383
- If middlewares need a client specific configuration, `Config#custom` can be used
383
+ If middlewares need a client-specific configuration, `Config#custom` can be used
384
384
 
385
385
  ```ruby
386
386
  module MyGlobalRedisInstrumentation
@@ -454,9 +454,9 @@ redis_config = RedisClient.config(reconnect_attempts: [0, 0.05, 0.1])
454
454
  ```
455
455
 
456
456
  This configuration is generally used when the Redis server is expected to failover or recover relatively quickly and
457
- that it's not really possibe to continue without issuing the command.
457
+ that it's not really possible to continue without issuing the command.
458
458
 
459
- When the Redis server is used as an ephemeral cache, circuit breakers are generally prefered.
459
+ When the Redis server is used as an ephemeral cache, circuit breakers are generally preferred.
460
460
 
461
461
  ### Circuit Breaker
462
462
 
@@ -24,10 +24,6 @@ class RedisClient
24
24
  @io.to_io.close
25
25
  end
26
26
 
27
- def reopen(*args)
28
- @io.to_io.reopen(*args)
29
- end
30
-
31
27
  def closed?
32
28
  @io.to_io.closed?
33
29
  end
@@ -58,13 +58,6 @@ class RedisClient
58
58
  super
59
59
  end
60
60
 
61
- def discard
62
- unless @io.closed?
63
- @io.reopen(File::NULL)
64
- end
65
- close
66
- end
67
-
68
61
  def read_timeout=(timeout)
69
62
  @read_timeout = timeout
70
63
  @io.read_timeout = timeout if @io
@@ -10,7 +10,7 @@ class RedisClient
10
10
  attr_reader :name
11
11
 
12
12
  def initialize(sentinels:, role: :master, name: nil, url: nil, **client_config)
13
- unless %i(master replica slave).include?(role)
13
+ unless %i(master replica slave).include?(role.to_sym)
14
14
  raise ArgumentError, "Expected role to be either :master or :replica, got: #{role.inspect}"
15
15
  end
16
16
 
@@ -43,7 +43,7 @@ class RedisClient
43
43
  end
44
44
 
45
45
  @sentinels = {}.compare_by_identity
46
- @role = role
46
+ @role = role.to_sym
47
47
  @mutex = Mutex.new
48
48
  @config = nil
49
49
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.15.0"
4
+ VERSION = "0.16.0"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -358,9 +358,8 @@ class RedisClient
358
358
  self
359
359
  end
360
360
 
361
- def discard
362
- @raw_connection&.discard
363
- self
361
+ def disable_reconnection(&block)
362
+ ensure_connected(retryable: false, &block)
364
363
  end
365
364
 
366
365
  def pipelined
@@ -623,7 +622,7 @@ class RedisClient
623
622
  end
624
623
 
625
624
  def ensure_connected(retryable: true)
626
- discard if !config.inherit_socket && @pid != PIDCache.pid
625
+ close if !config.inherit_socket && @pid != PIDCache.pid
627
626
 
628
627
  if @disable_reconnection
629
628
  if block_given?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-01 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.3.7
80
+ rubygems_version: 3.4.10
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Simple low-level client for Redis 6+