Skip to content

Commit 2a48105

Browse files
authored
fix: use public_send method instead of send method (#174)
1 parent 2c9bed2 commit 2a48105

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/redis_client/cluster/node.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def build_replication_mappings(node_info_list) # rubocop:disable Metrics/AbcSize
285285

286286
def call_multiple_nodes(clients, method, command, args, &block)
287287
results, errors = try_map(clients) do |_, client|
288-
client.send(method, *args, command, &block)
288+
client.public_send(method, *args, command, &block)
289289
end
290290

291291
[results&.values, errors]

lib/redis_client/cluster/router.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def send_command(method, command, *args, &block) # rubocop:disable Metrics/AbcSi
6868
def try_send(node, method, command, args, retry_count: 3, &block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
6969
if args.empty?
7070
# prevent memory allocation for variable-length args
71-
node.send(method, command, &block)
71+
node.public_send(method, command, &block)
7272
else
73-
node.send(method, *args, command, &block)
73+
node.public_send(method, *args, command, &block)
7474
end
7575
rescue ::RedisClient::CommandError => e
7676
raise if retry_count <= 0
@@ -101,7 +101,7 @@ def try_send(node, method, command, args, retry_count: 3, &block) # rubocop:disa
101101
end
102102

103103
def try_delegate(node, method, *args, retry_count: 3, **kwargs, &block) # rubocop:disable Metrics/AbcSize
104-
node.send(method, *args, **kwargs, &block)
104+
node.public_send(method, *args, **kwargs, &block)
105105
rescue ::RedisClient::CommandError => e
106106
raise if retry_count <= 0
107107

@@ -214,15 +214,15 @@ def send_config_command(method, command, args, &block)
214214
case ::RedisClient::Cluster::NormalizedCmdName.instance.get_by_subcommand(command)
215215
when 'resetstat', 'rewrite', 'set'
216216
@node.call_all(method, command, args, &block).first
217-
else assign_node(command).send(method, *args, command, &block)
217+
else assign_node(command).public_send(method, *args, command, &block)
218218
end
219219
end
220220

221221
def send_memory_command(method, command, args, &block)
222222
case ::RedisClient::Cluster::NormalizedCmdName.instance.get_by_subcommand(command)
223223
when 'stats' then @node.call_all(method, command, args, &block)
224224
when 'purge' then @node.call_all(method, command, args, &block).first
225-
else assign_node(command).send(method, *args, command, &block)
225+
else assign_node(command).public_send(method, *args, command, &block)
226226
end
227227
end
228228

@@ -231,7 +231,7 @@ def send_client_command(method, command, args, &block)
231231
when 'list' then @node.call_all(method, command, args, &block).flatten
232232
when 'pause', 'reply', 'setname'
233233
@node.call_all(method, command, args, &block).first
234-
else assign_node(command).send(method, *args, command, &block)
234+
else assign_node(command).public_send(method, *args, command, &block)
235235
end
236236
end
237237

@@ -244,8 +244,8 @@ def send_cluster_command(method, command, args, &block)
244244
when 'getkeysinslot'
245245
raise ArgumentError, command.join(' ') if command.size != 4
246246

247-
find_node(@node.find_node_key_of_replica(command[2])).send(method, *args, command, &block)
248-
else assign_node(command).send(method, *args, command, &block)
247+
find_node(@node.find_node_key_of_replica(command[2])).public_send(method, *args, command, &block)
248+
else assign_node(command).public_send(method, *args, command, &block)
249249
end
250250
end
251251

@@ -255,7 +255,7 @@ def send_script_command(method, command, args, &block)
255255
@node.call_all(method, command, args, &block).first
256256
when 'flush', 'load'
257257
@node.call_primaries(method, command, args, &block).first
258-
else assign_node(command).send(method, *args, command, &block)
258+
else assign_node(command).public_send(method, *args, command, &block)
259259
end
260260
end
261261

@@ -266,7 +266,7 @@ def send_pubsub_command(method, command, args, &block) # rubocop:disable Metrics
266266
@node.call_all(method, command, args, &block).reject(&:empty?).map { |e| Hash[*e] }
267267
.reduce({}) { |a, e| a.merge(e) { |_, v1, v2| v1 + v2 } }
268268
when 'numpat' then @node.call_all(method, command, args, &block).select { |e| e.is_a?(Integer) }.sum
269-
else assign_node(command).send(method, *args, command, &block)
269+
else assign_node(command).public_send(method, *args, command, &block)
270270
end
271271
end
272272

0 commit comments

Comments
 (0)