redis-client 0.8.0 → 0.8.1

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: e7e7b7923ecb86353521db31036b3c5678683fcb6ed8ec5799c1ca6c6b5fcd44
4
- data.tar.gz: 9e782f9884b2f12eb0c58ca701da62e8945a14a1eca27c3052adbb0a1e4fe428
3
+ metadata.gz: e4699c416da87ac3ed64b078ac60643a3baaa7fc2e3884feb58cc86aeb619083
4
+ data.tar.gz: 5305b72684041089b57c12f493b16e81901718654058e2a5f920b18bb2b83792
5
5
  SHA512:
6
- metadata.gz: c77d09a8330bbcc4e8b2329a1ff9e660bb2c5ddf35cccafcf89f0b37ef9d89f579fa32b9ec7a7f64eecff12941ac835e4424dcf7ab9fdef12fc01ae73250959f
7
- data.tar.gz: 4c16639282ca539e04d07d363c28e663a5e409f6c6d9deef856158fe8d46a1e20669b44c025e978dc04965106148e1fd7fcd82cc1d50abc8c27fb4694b825e2e
6
+ metadata.gz: 119c4cf4e1a0eed4f9e67ad2be84fc6a63404cde61519a697efd85b643779cb41b30b32f765ec3308ccaf7fa4903684c9dab1ecb86b1289db2566b1943ac7010
7
+ data.tar.gz: dbcba8c22c20d4ac33d1e7a495bf95cb30bca7a8b63d98d8944f2c61abfefbf4a40fc3d3222591a85ab8936c5b9e83c946095458b9b31748fe3e3e4e4e37db9e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.8.1
4
+
5
+ - Make the client resilient to `Timeout.timeout` or `Thread#kill` use (it still still very much discouraged to use).
6
+ Use of async interrupts could cause responses to be interleaved.
7
+ - hiredis: handle commands returning a top-level `false` (no command does this today, but some extensions might).
8
+ - Workaround a bug in Ruby 2.6 causing a crash if the `debug` gem is enabled when `redis-client` is being required. Fix: #48
9
+
3
10
  # 0.8.0
4
11
 
5
12
  - Add a `connect` interface to the instrumentation API.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.8.0)
4
+ redis-client (0.8.1)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -10,7 +10,7 @@ GEM
10
10
  ast (2.4.2)
11
11
  benchmark-ips (2.10.0)
12
12
  byebug (11.1.3)
13
- connection_pool (2.2.5)
13
+ connection_pool (2.3.0)
14
14
  hiredis (0.6.3)
15
15
  hiredis (0.6.3-java)
16
16
  minitest (5.15.0)
@@ -2,9 +2,21 @@
2
2
 
3
3
  class RedisClient
4
4
  module ConnectionMixin
5
+ def initialize
6
+ @pending_reads = 0
7
+ end
8
+
9
+ def revalidate
10
+ if @pending_reads == 0 && connected?
11
+ self
12
+ end
13
+ end
14
+
5
15
  def call(command, timeout)
16
+ @pending_reads += 1
6
17
  write(command)
7
18
  result = read(timeout)
19
+ @pending_reads -= 1
8
20
  if result.is_a?(CommandError)
9
21
  result._set_command(command)
10
22
  raise result
@@ -18,11 +30,13 @@ class RedisClient
18
30
 
19
31
  size = commands.size
20
32
  results = Array.new(commands.size)
33
+ @pending_reads += size
21
34
  write_multi(commands)
22
35
 
23
36
  size.times do |index|
24
37
  timeout = timeouts && timeouts[index]
25
38
  result = read(timeout)
39
+ @pending_reads -= 1
26
40
  if result.is_a?(CommandError)
27
41
  result._set_command(commands[index])
28
42
  exception ||= result
@@ -51,46 +51,26 @@ class RedisClient
51
51
 
52
52
  methods = %w(pipelined multi pubsub call call_v call_once call_once_v blocking_call blocking_call_v)
53
53
  iterable_methods = %w(scan sscan hscan zscan)
54
- begin
55
- methods.each do |method|
56
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
57
- def #{method}(...)
58
- with { |r| r.#{method}(...) }
59
- end
60
- RUBY
61
- end
62
-
63
- iterable_methods.each do |method|
64
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
65
- def #{method}(...)
66
- unless block_given?
67
- return to_enum(__callee__, ...)
68
- end
54
+ methods.each do |method|
55
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
56
+ def #{method}(*args, &block)
57
+ with { |r| r.#{method}(*args, &block) }
58
+ end
59
+ ruby2_keywords :#{method} if respond_to?(:ruby2_keywords, true)
60
+ RUBY
61
+ end
69
62
 
70
- with { |r| r.#{method}(...) }
71
- end
72
- RUBY
73
- end
74
- rescue SyntaxError
75
- methods.each do |method|
76
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
77
- def #{method}(*args, &block)
78
- with { |r| r.#{method}(*args, &block) }
63
+ iterable_methods.each do |method|
64
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
65
+ def #{method}(*args, &block)
66
+ unless block_given?
67
+ return to_enum(__callee__, *args)
79
68
  end
80
- RUBY
81
- end
82
-
83
- iterable_methods.each do |method|
84
- class_eval <<~RUBY, __FILE__, __LINE__ + 1
85
- def #{method}(*args, &block)
86
- unless block_given?
87
- return to_enum(__callee__, *args)
88
- end
89
69
 
90
- with { |r| r.#{method}(*args, &block) }
91
- end
92
- RUBY
93
- end
70
+ with { |r| r.#{method}(*args, &block) }
71
+ end
72
+ ruby2_keywords :#{method} if respond_to?(:ruby2_keywords, true)
73
+ RUBY
94
74
  end
95
75
 
96
76
  private
@@ -41,6 +41,7 @@ class RedisClient
41
41
  SUPPORTS_RESOLV_TIMEOUT = Socket.method(:tcp).parameters.any? { |p| p.last == :resolv_timeout }
42
42
 
43
43
  def initialize(config, connect_timeout:, read_timeout:, write_timeout:)
44
+ super()
44
45
  socket = if config.path
45
46
  UNIXSocket.new(config.path)
46
47
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.8.0"
4
+ VERSION = "0.8.1"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -641,6 +641,7 @@ class RedisClient
641
641
  end
642
642
 
643
643
  def raw_connection
644
+ @raw_connection = @raw_connection&.revalidate
644
645
  @raw_connection ||= connect
645
646
  end
646
647
 
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.8.0
4
+ version: 0.8.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-09-07 00:00:00.000000000 Z
11
+ date: 2022-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool