Skip to content

Commit 26bdba4

Browse files
authored
refactor: lessen responsibility in a method (#252)
1 parent 2913d73 commit 26bdba4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/redis_client/cluster/pipeline.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def execute # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Met
149149
all_replies = errors = nil
150150
@pipelines&.each_slice(MAX_THREADS) do |chuncked_pipelines|
151151
chuncked_pipelines
152-
.map { |node_key, pipeline| [node_key, build_thread_for_pipeline(@router, node_key, pipeline)] }
152+
.map { |node_key, pipeline| [node_key, build_thread_for_pipeline(@router.find_node(node_key), pipeline)] }
153153
.each do |node_key, thread|
154154
case v = thread.value
155155
when ::RedisClient::Cluster::Pipeline::RedirectionNeeded
@@ -182,9 +182,9 @@ def append_pipeline(node_key)
182182
@pipelines[node_key]
183183
end
184184

185-
def build_thread_for_pipeline(router, node_key, pipeline)
186-
Thread.new(router, node_key, pipeline) do |rt, nk, pl|
187-
replies = do_pipelining(rt.find_node(nk), pl)
185+
def build_thread_for_pipeline(client, pipeline)
186+
Thread.new(client, pipeline) do |cli, pl|
187+
replies = do_pipelining(cli, pl)
188188
raise ReplySizeError, "commands: #{pl._size}, replies: #{replies.size}" if pl._size != replies.size
189189

190190
replies

0 commit comments

Comments
 (0)