redis-client 0.6.1 → 0.7.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: c3b26d6232b408310d32fda820a8d89263dccd3d3af1ab9518f2f398fdcb94c5
4
- data.tar.gz: af204813327a82cf9a80dd22ee7b5528f67df200765561bcb0e399bdd5b0e829
3
+ metadata.gz: a4170ea87f36925fbfdd698282bfaacc9d922c5cdb2a3474944cbf1ad10f86a4
4
+ data.tar.gz: 46add9543d181621ebb5c54594318d4111c00c8153083b3c84c9363693eceb95
5
5
  SHA512:
6
- metadata.gz: 3754bcdfb70484753fb67e69cbc0b071eb7dacbef67a48edb59dd55a8c79094a84b3ca96caa7f0f8ac0969ce24433688d81eba2bca3b27be79bb60600a1ff1a8
7
- data.tar.gz: 998dd6e7b0cf8d92880b473aee858f19e3bff1da2ce670f4c4fae3e43e2f534a8cf2cdd1aca064036bc7c20cea660ad69d3611d80c15f5679ca78bef1747e637
6
+ metadata.gz: ae48b57736db4a41686f2e9462b85c193ebe75bf323d2684c89ae5905aa4000cd69c806fd1ee9d63a117ad6e35a6d4befd28779938726e2ab4932273e32dbe46
7
+ data.tar.gz: d17c48e6252575b6842bff27dee3a608f066a9646684d675a2bd9bfd8285c308797c8359137b213f6d736377324e6d10b5f4e3fd306e605d891b14cef93f906f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.7.1
4
+
5
+ - Fix `#pubsub` being called when reconnection is disabled (redis-rb compatibility fix).
6
+
7
+ # 0.7.0
8
+
9
+ - Sentinel config now accept a list of URLs: `RedisClient.sentinel(sentinels: %w(redis://example.com:7000 redis://example.com:7001 ..))`
10
+
11
+ # 0.6.2
12
+
13
+ - Fix sentinel to not connected to s_down or o_down replicas.
14
+
3
15
  # 0.6.1
4
16
 
5
17
  - Fix `REDIS_REPLY_SET` parsing in `hiredis`.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.6.1)
4
+ redis-client (0.7.1)
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.1"
4
+ VERSION = "0.7.1"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -589,7 +589,11 @@ class RedisClient
589
589
 
590
590
  def ensure_connected(retryable: true)
591
591
  if @disable_reconnection
592
- yield @raw_connection
592
+ if block_given?
593
+ yield @raw_connection
594
+ else
595
+ @raw_connection
596
+ end
593
597
  elsif retryable
594
598
  tries = 0
595
599
  connection = nil
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.1
4
+ version: 0.7.1
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-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool