Skip to content

Commit 4288704

Browse files
committed
Accept a client_implementation like redis-client
1 parent cfb2b7a commit 4288704

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/redis_client/cluster_config.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ class ClusterConfig
2222

2323
attr_reader :command_builder
2424

25-
def initialize(nodes: DEFAULT_NODES, replica: false, fixed_hostname: '', **client_config)
25+
def initialize(nodes: DEFAULT_NODES, replica: false, client_implementation: Cluster, fixed_hostname: '', **client_config)
2626
@replica = true & replica
2727
@fixed_hostname = fixed_hostname.to_s
2828
@node_configs = build_node_configs(nodes.dup)
2929
client_config = client_config.reject { |k, _| IGNORE_GENERIC_CONFIG_KEYS.include?(k) }
3030
@command_builder = client_config.fetch(:command_builder, ::RedisClient::CommandBuilder)
3131
@client_config = merge_generic_config(client_config, @node_configs)
32+
@client_implementation = client_implementation
3233
@mutex = Mutex.new
3334
end
3435

@@ -37,11 +38,11 @@ def inspect
3738
end
3839

3940
def new_pool(size: 5, timeout: 5, **kwargs)
40-
::RedisClient::Cluster.new(self, pool: { size: size, timeout: timeout }, **kwargs)
41+
@client_implementation.new(self, pool: { size: size, timeout: timeout }, **kwargs)
4142
end
4243

4344
def new_client(**kwargs)
44-
::RedisClient::Cluster.new(self, **kwargs)
45+
@client_implementation.new(self, **kwargs)
4546
end
4647

4748
def per_node_key

0 commit comments

Comments
 (0)