MCPcopy
hub / github.com/redis/go-redis / pickArbitraryNode

Method pickArbitraryNode

osscluster_router.go:491–501  ·  view source on GitHub ↗

pickArbitraryNode selects a master or slave shard using the configured ShardPicker

(ctx context.Context)

Source from the content-addressed store, hash-verified

489
490// pickArbitraryNode selects a master or slave shard using the configured ShardPicker
491func (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
504func (c *ClusterClient) hasKeys(cmd Cmder) bool {

Callers 1

Calls 2

GetMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected