MCPcopy Create free account
hub / github.com/coder/coder / Coordinate

Method Coordinate

enterprise/tailnet/pgcoord.go:245–277  ·  view source on GitHub ↗
(
	ctx context.Context, id uuid.UUID, name string, a agpl.CoordinateeAuth,
)

Source from the content-addressed store, hash-verified

243}
244
245func (c *pgCoord) Coordinate(
246 ctx context.Context, id uuid.UUID, name string, a agpl.CoordinateeAuth,
247) (
248 chan<- *proto.CoordinateRequest, <-chan *proto.CoordinateResponse,
249) {
250 logger := c.logger.With(slog.F("peer_id", id))
251 reqs := make(chan *proto.CoordinateRequest, agpl.RequestBufferSize)
252 resps := make(chan *proto.CoordinateResponse, agpl.ResponseBufferSize)
253 if !c.querier.isHealthy() {
254 // If the coordinator is unhealthy, we don't want to hook this Coordinate call up to the
255 // binder, as that can cause an unnecessary call to DeleteTailnetPeer when the connIO is
256 // closed. Instead, we just close the response channel and bail out.
257 // c.f. https://github.com/coder/coder/issues/12923
258 c.logger.Info(ctx, "closed incoming coordinate call while unhealthy",
259 slog.F("peer_id", id),
260 )
261 resps <- &proto.CoordinateResponse{Error: CloseErrUnhealthy}
262 close(resps)
263 return reqs, resps
264 }
265 cIO := newConnIO(c.ctx, ctx, logger, c.bindings, c.tunnelerCh, c.handshakerCh, reqs, resps, id, name, a)
266 err := agpl.SendCtx(c.ctx, c.newConnections, cIO)
267 if err != nil {
268 // this can only happen if the context is canceled, no need to log
269 return reqs, resps
270 }
271 go func() {
272 <-cIO.Done()
273 _ = agpl.SendCtx(c.ctx, c.closeConnections, cIO)
274 }()
275
276 return reqs, resps
277}
278
279type tKey struct {
280 src uuid.UUID

Callers

nothing calls this directly

Calls 4

newConnIOFunction · 0.85
isHealthyMethod · 0.80
InfoMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected