Skip to content

Commit d00d1e1

Browse files
authored
Merge pull request #92 from redis-rb/timeout-and-blocking-calls
Expose #config to allow accessing read_timeout
2 parents 739bbaf + c6e063c commit d00d1e1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

lib/redis_client/cluster.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ class RedisClient
88
class Cluster
99
ZERO_CURSOR_FOR_SCAN = '0'
1010

11+
attr_reader :config
12+
1113
def initialize(config, pool: nil, **kwargs)
14+
@config = config
1215
@router = ::RedisClient::Cluster::Router.new(config, pool: pool, **kwargs)
1316
@command_builder = config.command_builder
1417
end

lib/redis_client/cluster_config.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ClusterConfig
2020

2121
InvalidClientConfigError = Class.new(::RedisClient::Error)
2222

23-
attr_reader :command_builder
23+
attr_reader :command_builder, :client_config
2424

2525
def initialize(nodes: DEFAULT_NODES, replica: false, client_implementation: Cluster, fixed_hostname: '', **client_config)
2626
@replica = true & replica
@@ -37,6 +37,10 @@ def inspect
3737
"#<#{self.class.name} #{per_node_key.values}>"
3838
end
3939

40+
def read_timeout
41+
@client_config[:read_timeout] || @client_config[:timeout] || RedisClient::Config::DEFAULT_TIMEOUT
42+
end
43+
4044
def new_pool(size: 5, timeout: 5, **kwargs)
4145
@client_implementation.new(self, pool: { size: size, timeout: timeout }, **kwargs)
4246
end

test/redis_client/test_cluster.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ def teardown
1717
@client&.close
1818
end
1919

20+
def test_config
21+
refute_nil @client.config
22+
refute_nil @client.config.read_timeout
23+
end
24+
2025
def test_inspect
2126
assert_match(/^#<RedisClient::Cluster [0-9., :]*>$/, @client.inspect)
2227
end

0 commit comments

Comments
 (0)