| 234 | } |
| 235 | |
| 236 | func (cluster *Cluster) SetSlot(ctx context.Context, slot int, targetNodeID string) error { |
| 237 | version := cluster.Version.Add(1) |
| 238 | for i := 0; i < len(cluster.Shards); i++ { |
| 239 | for _, node := range cluster.Shards[i].Nodes { |
| 240 | clusterNode, ok := node.(*ClusterNode) |
| 241 | if !ok { |
| 242 | continue |
| 243 | } |
| 244 | err := clusterNode.GetClient().Do(ctx, "CLUSTERX", "SETSLOT", slot, "NODE", targetNodeID, version).Err() |
| 245 | if err != nil { |
| 246 | return err |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | return nil |
| 251 | } |
| 252 | |
| 253 | // ParseCluster will parse the cluster string into cluster topology. |
| 254 | func ParseCluster(clusterStr string) (*Cluster, error) { |