redis-client 0.7.2 → 0.8.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: 81e19420827bc96f40097f45a68660c9158a72de1bf181a4a1713d12630964f0
4
- data.tar.gz: ea48a355e633b2b54415e06b1fdff363879296ffb67085b97ee67ee52ec0e4dd
3
+ metadata.gz: e7e7b7923ecb86353521db31036b3c5678683fcb6ed8ec5799c1ca6c6b5fcd44
4
+ data.tar.gz: 9e782f9884b2f12eb0c58ca701da62e8945a14a1eca27c3052adbb0a1e4fe428
5
5
  SHA512:
6
- metadata.gz: a01f575d01adb1260d01be754ccbd3e39d03415ed4ce4f28998bfe081b298eff041a39acefbc594a058647968e6d9e5ae245f58dc05889243428abd731fc01e8
7
- data.tar.gz: '099a087f0f32deb096302080128b817f0472be41bdce36e4df05d0d3404b2329661aa353491a388a671765349bf170c76c1284d84ffa24981ef3e46647225770'
6
+ metadata.gz: c77d09a8330bbcc4e8b2329a1ff9e660bb2c5ddf35cccafcf89f0b37ef9d89f579fa32b9ec7a7f64eecff12941ac835e4424dcf7ab9fdef12fc01ae73250959f
7
+ data.tar.gz: 4c16639282ca539e04d07d363c28e663a5e409f6c6d9deef856158fe8d46a1e20669b44c025e978dc04965106148e1fd7fcd82cc1d50abc8c27fb4694b825e2e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.8.0
4
+
5
+ - Add a `connect` interface to the instrumentation API.
6
+
7
+ # 0.7.4
8
+
9
+ - Properly parse script errors on pre 7.0 redis server.
10
+
11
+ # 0.7.3
12
+
13
+ - Fix a bug in `url` parsing conflicting with the `path` option.
14
+
3
15
  # 0.7.2
4
16
 
5
17
  - Raise a distinct `RedisClient::OutOfMemoryError`, for Redis `OOM` errors.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.7.2)
4
+ redis-client (0.8.0)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -38,7 +38,7 @@ GEM
38
38
  rubocop-minitest (0.19.1)
39
39
  rubocop (>= 0.90, < 2.0)
40
40
  ruby-progressbar (1.11.0)
41
- stackprof (0.2.19)
41
+ stackprof (0.2.21)
42
42
  toxiproxy (2.0.2)
43
43
  unicode-display_width (2.2.0)
44
44
 
data/README.md CHANGED
@@ -349,6 +349,10 @@ end
349
349
 
350
350
  ```ruby
351
351
  module MyRedisInstrumentation
352
+ def connect(redis_config)
353
+ MyMonitoringService.instrument("redis.connect") { super }
354
+ end
355
+
352
356
  def call(command, redis_config)
353
357
  MyMonitoringService.instrument("redis.query") { super }
354
358
  end
@@ -149,8 +149,8 @@ class RedisClient
149
149
  URI.decode_www_form_component(uri.password)
150
150
  end
151
151
 
152
- path = uri.path&.delete_prefix("/")
153
- kwargs[:db] ||= Integer(path) if path && !path.empty?
152
+ db_path = uri.path&.delete_prefix("/")
153
+ kwargs[:db] ||= Integer(db_path) if db_path && !db_path.empty?
154
154
  end
155
155
 
156
156
  super(**kwargs)
@@ -4,6 +4,10 @@ class RedisClient
4
4
  module Middlewares
5
5
  extend self
6
6
 
7
+ def connect(_config)
8
+ yield
9
+ end
10
+
7
11
  def call(command, _config)
8
12
  yield command
9
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.7.2"
4
+ VERSION = "0.8.0"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -94,7 +94,14 @@ class RedisClient
94
94
 
95
95
  class << self
96
96
  def parse(error_message)
97
- code = error_message.split(' ', 2).first
97
+ code = if error_message.start_with?("ERR Error running script")
98
+ # On older redis servers script errors are nested.
99
+ # So we need to parse some more.
100
+ if (match = error_message.match(/:\s-([A-Z]+) /))
101
+ match[1]
102
+ end
103
+ end
104
+ code ||= error_message.split(' ', 2).first
98
105
  klass = ERRORS.fetch(code, self)
99
106
  klass.new(error_message)
100
107
  end
@@ -638,12 +645,14 @@ class RedisClient
638
645
  end
639
646
 
640
647
  def connect
641
- connection = config.driver.new(
642
- config,
643
- connect_timeout: connect_timeout,
644
- read_timeout: read_timeout,
645
- write_timeout: write_timeout,
646
- )
648
+ connection = Middlewares.connect(config) do
649
+ config.driver.new(
650
+ config,
651
+ connect_timeout: connect_timeout,
652
+ read_timeout: read_timeout,
653
+ write_timeout: write_timeout,
654
+ )
655
+ end
647
656
 
648
657
  prelude = config.connection_prelude.dup
649
658
 
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.7.2
4
+ version: 0.8.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-09-05 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool