@@ -54,25 +54,12 @@ func (c *ClusterClient) routeAndRun(ctx context.Context, cmd Cmder, node *cluste
5454
5555// executeDefault handles standard command routing based on keys
5656func (c * ClusterClient ) executeDefault (ctx context.Context , cmd Cmder , policy * routing.CommandPolicy , node * clusterNode ) error {
57- if c .hasKeys (cmd ) {
58- // execute on key based shard
59- return node .Client .Process (ctx , cmd )
60- }
61- if policy != nil {
57+ if policy != nil && ! c .hasKeys (cmd ) {
6258 if c .readOnlyEnabled () && policy .IsReadOnly () {
6359 return c .executeOnArbitraryNode (ctx , cmd )
6460 }
6561 }
6662
67- return c .executeOnArbitraryShard (ctx , cmd )
68- }
69-
70- // executeOnArbitraryShard routes command to an arbitrary shard
71- func (c * ClusterClient ) executeOnArbitraryShard (ctx context.Context , cmd Cmder ) error {
72- node := c .pickArbitraryShard (ctx )
73- if node == nil {
74- return errClusterNoNodes
75- }
7663 return node .Client .Process (ctx , cmd )
7764}
7865
@@ -492,17 +479,6 @@ func (c *ClusterClient) finishAggregation(cmd Cmder, aggregator routing.Response
492479 return c .setCommandValue (cmd , finalValue )
493480}
494481
495- // pickArbitraryShard selects a master shard using the configured ShardPicker
496- func (c * ClusterClient ) pickArbitraryShard (ctx context.Context ) * clusterNode {
497- state , err := c .state .Get (ctx )
498- if err != nil || len (state .Masters ) == 0 {
499- return nil
500- }
501-
502- idx := c .opt .ShardPicker .Next (len (state .Masters ))
503- return state .Masters [idx ]
504- }
505-
506482// pickArbitraryNode selects a master or slave shard using the configured ShardPicker
507483func (c * ClusterClient ) pickArbitraryNode (ctx context.Context ) * clusterNode {
508484 state , err := c .state .Get (ctx )
0 commit comments