@@ -838,7 +838,7 @@ type ClusterClient struct {
838
838
state * clusterStateHolder
839
839
cmdsInfoCache * cmdsInfoCache
840
840
cmdable
841
- hooks
841
+ hooksMixin
842
842
}
843
843
844
844
// NewClusterClient returns a Redis Cluster client as described in
@@ -855,9 +855,12 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {
855
855
c .cmdsInfoCache = newCmdsInfoCache (c .cmdsInfo )
856
856
c .cmdable = c .Process
857
857
858
- c .hooks .setProcess (c .process )
859
- c .hooks .setProcessPipeline (c .processPipeline )
860
- c .hooks .setProcessTxPipeline (c .processTxPipeline )
858
+ c .initHooks (hooks {
859
+ dial : nil ,
860
+ process : c .process ,
861
+ pipeline : c .processPipeline ,
862
+ txPipeline : c .processTxPipeline ,
863
+ })
861
864
862
865
return c
863
866
}
@@ -889,7 +892,7 @@ func (c *ClusterClient) Do(ctx context.Context, args ...interface{}) *Cmd {
889
892
}
890
893
891
894
func (c * ClusterClient ) Process (ctx context.Context , cmd Cmder ) error {
892
- err := c .hooks . process (ctx , cmd )
895
+ err := c .processHook (ctx , cmd )
893
896
cmd .SetErr (err )
894
897
return err
895
898
}
@@ -1187,7 +1190,7 @@ func (c *ClusterClient) loadState(ctx context.Context) (*clusterState, error) {
1187
1190
1188
1191
func (c * ClusterClient ) Pipeline () Pipeliner {
1189
1192
pipe := Pipeline {
1190
- exec : pipelineExecer (c .hooks . processPipeline ),
1193
+ exec : pipelineExecer (c .processPipelineHook ),
1191
1194
}
1192
1195
pipe .init ()
1193
1196
return & pipe
@@ -1276,7 +1279,7 @@ func (c *ClusterClient) cmdsAreReadOnly(ctx context.Context, cmds []Cmder) bool
1276
1279
func (c * ClusterClient ) processPipelineNode (
1277
1280
ctx context.Context , node * clusterNode , cmds []Cmder , failedCmds * cmdsMap ,
1278
1281
) {
1279
- _ = node .Client .hooks . withProcessPipelineHook (ctx , cmds , func (ctx context.Context , cmds []Cmder ) error {
1282
+ _ = node .Client .withProcessPipelineHook (ctx , cmds , func (ctx context.Context , cmds []Cmder ) error {
1280
1283
cn , err := node .Client .getConn (ctx )
1281
1284
if err != nil {
1282
1285
_ = c .mapCmdsByNode (ctx , failedCmds , cmds )
@@ -1380,7 +1383,7 @@ func (c *ClusterClient) TxPipeline() Pipeliner {
1380
1383
pipe := Pipeline {
1381
1384
exec : func (ctx context.Context , cmds []Cmder ) error {
1382
1385
cmds = wrapMultiExec (ctx , cmds )
1383
- return c .hooks . processTxPipeline (ctx , cmds )
1386
+ return c .processTxPipelineHook (ctx , cmds )
1384
1387
},
1385
1388
}
1386
1389
pipe .init ()
@@ -1453,7 +1456,7 @@ func (c *ClusterClient) processTxPipelineNode(
1453
1456
ctx context.Context , node * clusterNode , cmds []Cmder , failedCmds * cmdsMap ,
1454
1457
) {
1455
1458
cmds = wrapMultiExec (ctx , cmds )
1456
- _ = node .Client .hooks . withProcessPipelineHook (ctx , cmds , func (ctx context.Context , cmds []Cmder ) error {
1459
+ _ = node .Client .withProcessPipelineHook (ctx , cmds , func (ctx context.Context , cmds []Cmder ) error {
1457
1460
cn , err := node .Client .getConn (ctx )
1458
1461
if err != nil {
1459
1462
_ = c .mapCmdsByNode (ctx , failedCmds , cmds )
0 commit comments