redis-client 0.6.2 → 0.7.2

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: 2b3a285f6dbfb718f7fa429e962dbb955f3109cf67d785869076c8f0407d7d45
4
- data.tar.gz: e7e56c056e9eaabc96e438474c70bd2a3ff46a386c28cc891c4b13acbd255492
3
+ metadata.gz: 81e19420827bc96f40097f45a68660c9158a72de1bf181a4a1713d12630964f0
4
+ data.tar.gz: ea48a355e633b2b54415e06b1fdff363879296ffb67085b97ee67ee52ec0e4dd
5
5
  SHA512:
6
- metadata.gz: 0f70dfa045ca15360ba86f18cfa278a98296531b20b661a39abc8788091ff34f5407ec084e48fac45e1a2362f9741512ab35bfcc93d3fd16b3170fd188c57373
7
- data.tar.gz: eee07f8f34ba002f46201e50d2d72ff6f05192ccaa06ae23e952bde1008f2b33783afda48ac37ad70d512619395ac442d129d305adf78c17eced954edd9922fa
6
+ metadata.gz: a01f575d01adb1260d01be754ccbd3e39d03415ed4ce4f28998bfe081b298eff041a39acefbc594a058647968e6d9e5ae245f58dc05889243428abd731fc01e8
7
+ data.tar.gz: '099a087f0f32deb096302080128b817f0472be41bdce36e4df05d0d3404b2329661aa353491a388a671765349bf170c76c1284d84ffa24981ef3e46647225770'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.7.2
4
+
5
+ - Raise a distinct `RedisClient::OutOfMemoryError`, for Redis `OOM` errors.
6
+ - Fix the instrumentation API to be called even for authentication commands.
7
+ - Fix `url:` configuration to accept a trailing slash.
8
+
9
+ # 0.7.1
10
+
11
+ - Fix `#pubsub` being called when reconnection is disabled (redis-rb compatibility fix).
12
+
13
+ # 0.7.0
14
+
15
+ - Sentinel config now accept a list of URLs: `RedisClient.sentinel(sentinels: %w(redis://example.com:7000 redis://example.com:7001 ..))`
16
+
3
17
  # 0.6.2
4
18
 
5
19
  - Fix sentinel to not connected to s_down or o_down replicas.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.6.2)
4
+ redis-client (0.7.2)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -14,33 +14,33 @@ GEM
14
14
  hiredis (0.6.3)
15
15
  hiredis (0.6.3-java)
16
16
  minitest (5.15.0)
17
- parallel (1.21.0)
18
- parser (3.1.1.0)
17
+ parallel (1.22.1)
18
+ parser (3.1.2.1)
19
19
  ast (~> 2.4.1)
20
20
  rainbow (3.1.1)
21
21
  rake (13.0.6)
22
- rake-compiler (1.1.9)
22
+ rake-compiler (1.2.0)
23
23
  rake
24
24
  redis (4.6.0)
25
- regexp_parser (2.2.1)
25
+ regexp_parser (2.5.0)
26
26
  rexml (3.2.5)
27
- rubocop (1.25.1)
27
+ rubocop (1.28.2)
28
28
  parallel (~> 1.10)
29
29
  parser (>= 3.1.0.0)
30
30
  rainbow (>= 2.2.2, < 4.0)
31
31
  regexp_parser (>= 1.8, < 3.0)
32
32
  rexml
33
- rubocop-ast (>= 1.15.1, < 2.0)
33
+ rubocop-ast (>= 1.17.0, < 2.0)
34
34
  ruby-progressbar (~> 1.7)
35
35
  unicode-display_width (>= 1.4.0, < 3.0)
36
- rubocop-ast (1.16.0)
36
+ rubocop-ast (1.17.0)
37
37
  parser (>= 3.1.1.0)
38
- rubocop-minitest (0.14.0)
38
+ rubocop-minitest (0.19.1)
39
39
  rubocop (>= 0.90, < 2.0)
40
40
  ruby-progressbar (1.11.0)
41
41
  stackprof (0.2.19)
42
- toxiproxy (2.0.0)
43
- unicode-display_width (2.1.0)
42
+ toxiproxy (2.0.2)
43
+ unicode-display_width (2.2.0)
44
44
 
45
45
  PLATFORMS
46
46
  ruby
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`
@@ -149,7 +149,8 @@ class RedisClient
149
149
  URI.decode_www_form_component(uri.password)
150
150
  end
151
151
 
152
- kwargs[:db] ||= Integer(uri.path.delete_prefix("/")) if uri.path && !uri.path.empty?
152
+ path = uri.path&.delete_prefix("/")
153
+ kwargs[:db] ||= Integer(path) if path && !path.empty?
153
154
  end
154
155
 
155
156
  super(**kwargs)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.6.2"
4
+ VERSION = "0.7.2"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -109,12 +109,14 @@ class RedisClient
109
109
  PermissionError = Class.new(CommandError)
110
110
  ReadOnlyError = Class.new(CommandError)
111
111
  WrongTypeError = Class.new(CommandError)
112
+ OutOfMemoryError = Class.new(CommandError)
112
113
 
113
114
  CommandError::ERRORS = {
114
115
  "WRONGPASS" => AuthenticationError,
115
116
  "NOPERM" => PermissionError,
116
117
  "READONLY" => ReadOnlyError,
117
118
  "WRONGTYPE" => WrongTypeError,
119
+ "OOM" => OutOfMemoryError,
118
120
  }.freeze
119
121
 
120
122
  class << self
@@ -589,7 +591,11 @@ class RedisClient
589
591
 
590
592
  def ensure_connected(retryable: true)
591
593
  if @disable_reconnection
592
- yield @raw_connection
594
+ if block_given?
595
+ yield @raw_connection
596
+ else
597
+ @raw_connection
598
+ end
593
599
  elsif retryable
594
600
  tries = 0
595
601
  connection = nil
@@ -648,11 +654,15 @@ class RedisClient
648
654
  # The connection prelude is deliberately not sent to Middlewares
649
655
  if config.sentinel?
650
656
  prelude << ["ROLE"]
651
- role, = connection.call_pipelined(prelude, nil).last
657
+ role, = Middlewares.call_pipelined(prelude, config) do
658
+ connection.call_pipelined(prelude, nil).last
659
+ end
652
660
  config.check_role!(role)
653
661
  else
654
662
  unless prelude.empty?
655
- connection.call_pipelined(prelude, nil)
663
+ Middlewares.call_pipelined(prelude, config) do
664
+ connection.call_pipelined(prelude, nil)
665
+ end
656
666
  end
657
667
  end
658
668
 
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.2
4
+ version: 0.7.2
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-17 00:00:00.000000000 Z
11
+ date: 2022-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool