pickArbitraryNode selects a master or slave shard using the configured ShardPicker
(ctx context.Context)
| 489 | |
| 490 | // pickArbitraryNode selects a master or slave shard using the configured ShardPicker |
| 491 | func (c *ClusterClient) pickArbitraryNode(ctx context.Context) *clusterNode { |
| 492 | state, err := c.state.Get(ctx) |
| 493 | if err != nil || len(state.Masters) == 0 { |
| 494 | return nil |
| 495 | } |
| 496 | |
| 497 | allNodes := append(state.Masters, state.Slaves...) |
| 498 | |
| 499 | idx := c.opt.ShardPicker.Next(len(allNodes)) |
| 500 | return allNodes[idx] |
| 501 | } |
| 502 | |
| 503 | // hasKeys checks if a command operates on keys |
| 504 | func (c *ClusterClient) hasKeys(cmd Cmder) bool { |
no test coverage detected