mirror of
https://github.com/redis/go-redis.git
synced 2025-12-02 06:22:31 +03:00
wip
This commit is contained in:
@@ -1037,7 +1037,6 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {
|
||||
pipeline: c.processPipeline,
|
||||
txPipeline: c.processTxPipeline,
|
||||
})
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -1046,6 +1045,24 @@ func (c *ClusterClient) Options() *ClusterOptions {
|
||||
return c.opt
|
||||
}
|
||||
|
||||
// AddHook adds a hook to the client.
|
||||
func (c *ClusterClient) AddHook(h Hook) {
|
||||
// Add hook only to nodes, not to the cluster client itself.
|
||||
// This prevents hooks from being called twice (once at cluster level, once at node level).
|
||||
// The cluster client delegates all commands to nodes, so hooks on nodes will be called.
|
||||
|
||||
if err := c.ForEachShard(context.Background(), func(ctx context.Context, node *Client) error {
|
||||
node.AddHook(h)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.nodes.OnNewNode(func(rdb *Client) {
|
||||
rdb.AddHook(h)
|
||||
})
|
||||
}
|
||||
|
||||
// ReloadState reloads cluster state. If available it calls ClusterSlots func
|
||||
// to get cluster slots information.
|
||||
func (c *ClusterClient) ReloadState(ctx context.Context) {
|
||||
|
||||
Reference in New Issue
Block a user