@@ -24,8 +24,8 @@ class Router
24
24
25
25
Action = Struct . new (
26
26
'RedisCommandRoutingAction' ,
27
- :action_method_name ,
28
- :after_action_proc ,
27
+ :method_name ,
28
+ :reply_transformer ,
29
29
keyword_init : true
30
30
)
31
31
@@ -48,10 +48,10 @@ def send_command(method, command, *args, &block) # rubocop:disable Metrics/AbcSi
48
48
return assign_node_and_send_command ( method , command , args , &block ) unless @dedicated_actions . key? ( command . first )
49
49
50
50
action = @dedicated_actions [ command . first ]
51
- return send ( action . action_method_name , method , command , args , &block ) if action . after_action_proc . nil?
51
+ return send ( action . method_name , method , command , args , &block ) if action . reply_transformer . nil?
52
52
53
- reply = send ( action . action_method_name , method , command , args )
54
- action . after_action_proc . call ( reply ) . then ( &TSF . call ( block ) )
53
+ reply = send ( action . method_name , method , command , args )
54
+ action . reply_transformer . call ( reply ) . then ( &TSF . call ( block ) )
55
55
rescue ::RedisClient ::CircuitBreaker ::OpenCircuitError
56
56
raise
57
57
rescue ::RedisClient ::Cluster ::Node ::ReloadNeeded
@@ -259,26 +259,26 @@ def close
259
259
260
260
def build_dedicated_actions # rubocop:disable Metrics/AbcSize
261
261
pick_first = -> ( reply ) { reply . first } # rubocop:disable Style/SymbolProc
262
- multiple_key_action = Action . new ( action_method_name : :send_multiple_keys_command )
263
- all_node_first_action = Action . new ( action_method_name : :send_command_to_all_nodes , after_action_proc : pick_first )
264
- primary_first_action = Action . new ( action_method_name : :send_command_to_primaries , after_action_proc : pick_first )
265
- not_supported_action = Action . new ( action_method_name : :fail_not_supported_command )
266
- keyless_action = Action . new ( action_method_name : :fail_keyless_command )
262
+ multiple_key_action = Action . new ( method_name : :send_multiple_keys_command )
263
+ all_node_first_action = Action . new ( method_name : :send_command_to_all_nodes , reply_transformer : pick_first )
264
+ primary_first_action = Action . new ( method_name : :send_command_to_primaries , reply_transformer : pick_first )
265
+ not_supported_action = Action . new ( method_name : :fail_not_supported_command )
266
+ keyless_action = Action . new ( method_name : :fail_keyless_command )
267
267
actions = {
268
- 'ping' => Action . new ( action_method_name : :send_ping_command , after_action_proc : pick_first ) ,
269
- 'wait' => Action . new ( action_method_name : :send_wait_command ) ,
270
- 'keys' => Action . new ( action_method_name : :send_command_to_replicas , after_action_proc : -> ( reply ) { reply . flatten . sort_by ( &:to_s ) } ) ,
271
- 'dbsize' => Action . new ( action_method_name : :send_command_to_replicas , after_action_proc : -> ( reply ) { reply . select { |e | e . is_a? ( Integer ) } . sum } ) ,
272
- 'scan' => Action . new ( action_method_name : :send_scan_command ) ,
273
- 'lastsave' => Action . new ( action_method_name : :send_command_to_all_nodes , after_action_proc : -> ( reply ) { reply . sort_by ( &:to_i ) } ) ,
274
- 'role' => Action . new ( action_method_name : :send_command_to_all_nodes ) ,
275
- 'config' => Action . new ( action_method_name : :send_config_command ) ,
276
- 'client' => Action . new ( action_method_name : :send_client_command ) ,
277
- 'cluster' => Action . new ( action_method_name : :send_cluster_command ) ,
278
- 'memory' => Action . new ( action_method_name : :send_memory_command ) ,
279
- 'script' => Action . new ( action_method_name : :send_script_command ) ,
280
- 'pubsub' => Action . new ( action_method_name : :send_pubsub_command ) ,
281
- 'watch' => Action . new ( action_method_name : :send_watch_command ) ,
268
+ 'ping' => Action . new ( method_name : :send_ping_command , reply_transformer : pick_first ) ,
269
+ 'wait' => Action . new ( method_name : :send_wait_command ) ,
270
+ 'keys' => Action . new ( method_name : :send_command_to_replicas , reply_transformer : -> ( reply ) { reply . flatten . sort_by ( &:to_s ) } ) ,
271
+ 'dbsize' => Action . new ( method_name : :send_command_to_replicas , reply_transformer : -> ( reply ) { reply . select { |e | e . is_a? ( Integer ) } . sum } ) ,
272
+ 'scan' => Action . new ( method_name : :send_scan_command ) ,
273
+ 'lastsave' => Action . new ( method_name : :send_command_to_all_nodes , reply_transformer : -> ( reply ) { reply . sort_by ( &:to_i ) } ) ,
274
+ 'role' => Action . new ( method_name : :send_command_to_all_nodes ) ,
275
+ 'config' => Action . new ( method_name : :send_config_command ) ,
276
+ 'client' => Action . new ( method_name : :send_client_command ) ,
277
+ 'cluster' => Action . new ( method_name : :send_cluster_command ) ,
278
+ 'memory' => Action . new ( method_name : :send_memory_command ) ,
279
+ 'script' => Action . new ( method_name : :send_script_command ) ,
280
+ 'pubsub' => Action . new ( method_name : :send_pubsub_command ) ,
281
+ 'watch' => Action . new ( method_name : :send_watch_command ) ,
282
282
'mget' => multiple_key_action ,
283
283
'mset' => multiple_key_action ,
284
284
'del' => multiple_key_action ,
0 commit comments