(ctx context.Context, n int)
| 505 | } |
| 506 | |
| 507 | func (c *MockCluster) Add(ctx context.Context, n int) error { |
| 508 | host := c.generate(n) |
| 509 | for _, h := range c.hosts { |
| 510 | if host.equal(h) { |
| 511 | return errors.New("host already added") |
| 512 | } |
| 513 | } |
| 514 | c.hosts = append(c.hosts, host) |
| 515 | err := c.maybeStart(ctx, host) |
| 516 | if err != nil { |
| 517 | return err |
| 518 | } |
| 519 | for _, s := range c.servers { |
| 520 | s.Add(host) |
| 521 | } |
| 522 | return nil |
| 523 | } |
| 524 | |
| 525 | func (c *MockCluster) maybeStart(ctx context.Context, host MockHost) error { |
| 526 | key := host.String() |