| 445 | } |
| 446 | |
| 447 | func (c *TunnelSrcCoordController) AddDestination(dest uuid.UUID) { |
| 448 | c.mu.Lock() |
| 449 | defer c.mu.Unlock() |
| 450 | c.Coordinatee.SetTunnelDestination(dest) // this prepares us for an ack |
| 451 | c.dests[dest] = struct{}{} |
| 452 | if c.coordination == nil { |
| 453 | return |
| 454 | } |
| 455 | err := c.coordination.SendRequest( |
| 456 | &proto.CoordinateRequest{ |
| 457 | AddTunnel: &proto.CoordinateRequest_Tunnel{Id: UUIDToByteSlice(dest)}, |
| 458 | }) |
| 459 | if err != nil { |
| 460 | c.coordination.SendErr(err) |
| 461 | cErr := c.coordination.client.Close() // close the client so we don't gracefully disconnect |
| 462 | if cErr != nil { |
| 463 | c.Logger.Debug(context.Background(), |
| 464 | "failed to close coordinator client after add tunnel failure", |
| 465 | slog.Error(cErr)) |
| 466 | } |
| 467 | c.coordination = nil |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | func (c *TunnelSrcCoordController) RemoveDestination(dest uuid.UUID) { |
| 472 | c.mu.Lock() |