@@ -1017,7 +1017,7 @@ type ClusterClient struct {
10171017 nodes * clusterNodes
10181018 state * clusterStateHolder
10191019 cmdsInfoCache * cmdsInfoCache
1020- cmdInfoResolver * CommandInfoResolver
1020+ cmdInfoResolver * commandInfoResolver
10211021 cmdable
10221022 hooksMixin
10231023}
@@ -1425,7 +1425,10 @@ func (c *ClusterClient) mapCmdsByNode(ctx context.Context, cmdsMap *cmdsMap, cmd
14251425
14261426 if c .opt .ReadOnly && c .cmdsAreReadOnly (ctx , cmds ) {
14271427 for _ , cmd := range cmds {
1428- policy := c .extractCommandInfo (ctx , cmd )
1428+ var policy * routing.CommandPolicy
1429+ if c .cmdInfoResolver != nil {
1430+ policy = c .cmdInfoResolver .GetCommandPolicy (ctx , cmd )
1431+ }
14291432 if policy != nil && ! policy .CanBeUsedInPipeline () {
14301433 return fmt .Errorf (
14311434 "redis: cannot pipeline command %q with request policy ReqAllNodes/ReqAllShards/ReqMultiShard; Note: This behavior is subject to change in the future" , cmd .Name (),
@@ -1442,7 +1445,10 @@ func (c *ClusterClient) mapCmdsByNode(ctx context.Context, cmdsMap *cmdsMap, cmd
14421445 }
14431446
14441447 for _ , cmd := range cmds {
1445- policy := c .extractCommandInfo (ctx , cmd )
1448+ var policy * routing.CommandPolicy
1449+ if c .cmdInfoResolver != nil {
1450+ policy = c .cmdInfoResolver .GetCommandPolicy (ctx , cmd )
1451+ }
14461452 if policy != nil && ! policy .CanBeUsedInPipeline () {
14471453 return fmt .Errorf (
14481454 "redis: cannot pipeline command %q with request policy ReqAllNodes/ReqAllShards/ReqMultiShard; Note: This behavior is subject to change in the future" , cmd .Name (),
@@ -2199,11 +2205,11 @@ func (c *ClusterClient) context(ctx context.Context) context.Context {
21992205 return context .Background ()
22002206}
22012207
2202- func (c * ClusterClient ) GetResolver () * CommandInfoResolver {
2208+ func (c * ClusterClient ) GetResolver () * commandInfoResolver {
22032209 return c .cmdInfoResolver
22042210}
22052211
2206- func (c * ClusterClient ) SetCommandInfoResolver (cmdInfoResolver * CommandInfoResolver ) {
2212+ func (c * ClusterClient ) SetCommandInfoResolver (cmdInfoResolver * commandInfoResolver ) {
22072213 c .cmdInfoResolver = cmdInfoResolver
22082214}
22092215
@@ -2218,9 +2224,9 @@ func (c *ClusterClient) extractCommandInfo(ctx context.Context, cmd Cmder) *rout
22182224
22192225// NewDynamicResolver returns a CommandInfoResolver
22202226// that uses the underlying cmdInfo cache to resolve the policies
2221- func (c * ClusterClient ) NewDynamicResolver () * CommandInfoResolver {
2222- return & CommandInfoResolver {
2223- resolve : c .extractCommandInfo ,
2227+ func (c * ClusterClient ) NewDynamicResolver () * commandInfoResolver {
2228+ return & commandInfoResolver {
2229+ resolveFunc : c .extractCommandInfo ,
22242230 }
22252231}
22262232
0 commit comments