| 418 | } |
| 419 | |
| 420 | func (c *TunnelSrcCoordController) New(client CoordinatorClient) CloserWaiter { |
| 421 | c.mu.Lock() |
| 422 | defer c.mu.Unlock() |
| 423 | b := c.BasicCoordinationController.NewCoordination(client) |
| 424 | c.coordination = b |
| 425 | // resync destinations on reconnect |
| 426 | for dest := range c.dests { |
| 427 | err := b.SendRequest(&proto.CoordinateRequest{ |
| 428 | AddTunnel: &proto.CoordinateRequest_Tunnel{Id: UUIDToByteSlice(dest)}, |
| 429 | }) |
| 430 | if err != nil { |
| 431 | b.SendErr(err) |
| 432 | c.coordination = nil |
| 433 | cErr := client.Close() |
| 434 | if cErr != nil { |
| 435 | c.Logger.Debug( |
| 436 | context.Background(), |
| 437 | "failed to close coordinator client after add tunnel failure", |
| 438 | slog.Error(cErr), |
| 439 | ) |
| 440 | } |
| 441 | break |
| 442 | } |
| 443 | } |
| 444 | return b |
| 445 | } |
| 446 | |
| 447 | func (c *TunnelSrcCoordController) AddDestination(dest uuid.UUID) { |
| 448 | c.mu.Lock() |