redis-client 0.6.0 → 0.7.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: 05e24d8136cd8dc878d579c850297b1a016133447fd1f6135bd29dba55cd764e
4
- data.tar.gz: 9f67aa59e1dfe2370f5f786ef3dea8076abe172301d263a13624b65cb2ab3888
3
+ metadata.gz: 43d0bd9c0a97bdf398a2eee688663b6aa18facfa54c03b77465872454c710dd6
4
+ data.tar.gz: 628f5bd32c2cf5f4dabc326152f47d9ee474a9db748a0778fd111b8b529f3e84
5
5
  SHA512:
6
- metadata.gz: 2e18d178c2d520073189c71f643c7da18f46f7324c75c8757fc28a8673599064c1678186b4a6833beacf40068498cb5bf19dc6175040caedc8e9286b13e079c2
7
- data.tar.gz: d682b304d13901199f71e3c77561eb6562d7dddeae37068e9a20c0e8383a7c12bfbd5c1b250a506990425f126884a5f8946ea7df335bf31ee89713df187b3490
6
+ metadata.gz: 8dd0782af2688e60628333605c57dcd54b97c38faf01f364e1599b85f34792139559e3a3f658e7b942d98438fa621725abbcad6101beec0d2a87076b34cbbd6c
7
+ data.tar.gz: d7be85daadf3495f856de253fbd5744f143f92b087489a91436460ae5ef86be3af02aa7cff00582a79bf17bfe7c28b328e08e116c47285d29ff35a9454c37762
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.7.0
4
+
5
+ - Sentinel config now accept a list of URLs: `RedisClient.sentinel(sentinels: %w(redis://example.com:7000 redis://example.com:7001 ..))`
6
+
7
+ # 0.6.2
8
+
9
+ - Fix sentinel to not connected to s_down or o_down replicas.
10
+
11
+ # 0.6.1
12
+
13
+ - Fix `REDIS_REPLY_SET` parsing in `hiredis`.
14
+
3
15
  # 0.6.0
4
16
 
5
17
  - Added `protocol: 2` options to talk with Redis 5 and older servers.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.6.0)
4
+ redis-client (0.7.0)
5
5
  connection_pool
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -100,6 +100,19 @@ redis_config = RedisClient.sentinel(
100
100
  )
101
101
  ```
102
102
 
103
+ or:
104
+
105
+ ```ruby
106
+ redis_config = RedisClient.sentinel(
107
+ name: "mymaster",
108
+ sentinels: [
109
+ "redis://127.0.0.1:26380",
110
+ "redis://127.0.0.1:26381",
111
+ ],
112
+ role: :master,
113
+ )
114
+ ```
115
+
103
116
  * The name identifies a group of Redis instances composed of a master and one or more replicas (`mymaster` in the example).
104
117
 
105
118
  * It is possible to optionally provide a role. The allowed roles are `:master`
@@ -26,7 +26,14 @@ class RedisClient
26
26
  end
27
27
 
28
28
  @name = name
29
- @sentinel_configs = sentinels.map { |s| Config.new(**extra_config, **s) }
29
+ @sentinel_configs = sentinels.map do |s|
30
+ case s
31
+ when String
32
+ Config.new(**extra_config, url: s)
33
+ else
34
+ Config.new(**extra_config, **s)
35
+ end
36
+ end
30
37
  @sentinels = {}.compare_by_identity
31
38
  @role = role
32
39
  @mutex = Mutex.new
@@ -116,10 +123,13 @@ class RedisClient
116
123
  def resolve_replica
117
124
  each_sentinel do |sentinel_client|
118
125
  replicas = sentinel_client.call("SENTINEL", "replicas", @name, &@to_list_of_hash)
126
+ replicas.reject! do |r|
127
+ flags = r["flags"].to_s.split(",")
128
+ flags.include?("s_down") || flags.include?("o_down")
129
+ end
119
130
  next if replicas.empty?
120
131
 
121
- replica = replicas.reject { |r| r["flags"].to_s.split(",").include?("disconnected") }.sample
122
- replica ||= replicas.sample
132
+ replica = replicas.sample
123
133
  return Config.new(host: replica["ip"], port: Integer(replica["port"]), **@client_config)
124
134
  end
125
135
  rescue ConnectionError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -600,7 +600,7 @@ class RedisClient
600
600
  else
601
601
  connection
602
602
  end
603
- rescue ConnectionError => error
603
+ rescue ConnectionError, ProtocolError => error
604
604
  connection&.close
605
605
  close
606
606
 
@@ -617,7 +617,7 @@ class RedisClient
617
617
  begin
618
618
  @disable_reconnection = true
619
619
  yield connection
620
- rescue ConnectionError
620
+ rescue ConnectionError, ProtocolError
621
621
  connection&.close
622
622
  close
623
623
  raise
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.6.0
4
+ version: 0.7.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: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool