@@ -925,7 +925,7 @@ type ClusterClient struct {
925925 nodes * clusterNodes
926926 state * clusterStateHolder
927927 cmdsInfoCache * cmdsInfoCache
928- cmdInfoResolver * CommandInfoResolver
928+ cmdInfoResolver * commandInfoResolver
929929 cmdable
930930 hooksMixin
931931}
@@ -1340,7 +1340,10 @@ func (c *ClusterClient) mapCmdsByNode(ctx context.Context, cmdsMap *cmdsMap, cmd
13401340
13411341 if c .opt .ReadOnly && c .cmdsAreReadOnly (ctx , cmds ) {
13421342 for _ , cmd := range cmds {
1343- policy := c .extractCommandInfo (ctx , cmd )
1343+ var policy * routing.CommandPolicy
1344+ if c .cmdInfoResolver != nil {
1345+ policy = c .cmdInfoResolver .GetCommandPolicy (ctx , cmd )
1346+ }
13441347 if policy != nil && ! policy .CanBeUsedInPipeline () {
13451348 return fmt .Errorf (
13461349 "redis: cannot pipeline command %q with request policy ReqAllNodes/ReqAllShards/ReqMultiShard; Note: This behavior is subject to change in the future" , cmd .Name (),
@@ -1357,7 +1360,10 @@ func (c *ClusterClient) mapCmdsByNode(ctx context.Context, cmdsMap *cmdsMap, cmd
13571360 }
13581361
13591362 for _ , cmd := range cmds {
1360- policy := c .extractCommandInfo (ctx , cmd )
1363+ var policy * routing.CommandPolicy
1364+ if c .cmdInfoResolver != nil {
1365+ policy = c .cmdInfoResolver .GetCommandPolicy (ctx , cmd )
1366+ }
13611367 if policy != nil && ! policy .CanBeUsedInPipeline () {
13621368 return fmt .Errorf (
13631369 "redis: cannot pipeline command %q with request policy ReqAllNodes/ReqAllShards/ReqMultiShard; Note: This behavior is subject to change in the future" , cmd .Name (),
@@ -1982,11 +1988,11 @@ func (c *ClusterClient) context(ctx context.Context) context.Context {
19821988 return context .Background ()
19831989}
19841990
1985- func (c * ClusterClient ) GetResolver () * CommandInfoResolver {
1991+ func (c * ClusterClient ) GetResolver () * commandInfoResolver {
19861992 return c .cmdInfoResolver
19871993}
19881994
1989- func (c * ClusterClient ) SetCommandInfoResolver (cmdInfoResolver * CommandInfoResolver ) {
1995+ func (c * ClusterClient ) SetCommandInfoResolver (cmdInfoResolver * commandInfoResolver ) {
19901996 c .cmdInfoResolver = cmdInfoResolver
19911997}
19921998
@@ -2001,9 +2007,9 @@ func (c *ClusterClient) extractCommandInfo(ctx context.Context, cmd Cmder) *rout
20012007
20022008// NewDynamicResolver returns a CommandInfoResolver
20032009// that uses the underlying cmdInfo cache to resolve the policies
2004- func (c * ClusterClient ) NewDynamicResolver () * CommandInfoResolver {
2005- return & CommandInfoResolver {
2006- resolve : c .extractCommandInfo ,
2010+ func (c * ClusterClient ) NewDynamicResolver () * commandInfoResolver {
2011+ return & commandInfoResolver {
2012+ resolveFunc : c .extractCommandInfo ,
20072013 }
20082014}
20092015
0 commit comments