(nodeID string)
| 131 | } |
| 132 | |
| 133 | func (shard *Shard) removeNode(nodeID string) error { |
| 134 | isFound := false |
| 135 | for i, node := range shard.Nodes { |
| 136 | if node.ID() != nodeID { |
| 137 | continue |
| 138 | } |
| 139 | if node.IsMaster() { |
| 140 | return fmt.Errorf("cannot remove master node: %w", consts.ErrInvalidArgument) |
| 141 | } |
| 142 | shard.Nodes = append(shard.Nodes[:i], shard.Nodes[i+1:]...) |
| 143 | isFound = true |
| 144 | } |
| 145 | if !isFound { |
| 146 | return consts.ErrNotFound |
| 147 | } |
| 148 | return nil |
| 149 | } |
| 150 | |
| 151 | func (shard *Shard) getNewMasterNodeIndex(ctx context.Context, masterNodeIndex int, preferredNodeID string) int { |
| 152 | newMasterNodeIndex := -1 |
no test coverage detected