MCPcopy Index your code
hub / github.com/coder/coder / recvLoop

Method recvLoop

tailnet/controllers.go:1181–1215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1179}
1180
1181func (t *tunnelUpdater) recvLoop() {
1182 t.logger.Debug(context.Background(), "tunnel updater recvLoop started")
1183 defer t.logger.Debug(context.Background(), "tunnel updater recvLoop done")
1184 defer close(t.recvLoopDone)
1185 updateKind := Snapshot
1186 for {
1187 update, err := t.client.Recv()
1188 if err != nil {
1189 t.logger.Debug(context.Background(), "failed to receive workspace Update", slog.Error(err))
1190 select {
1191 case t.errChan <- err:
1192 default:
1193 }
1194 return
1195 }
1196 t.logger.Debug(context.Background(), "got workspace update",
1197 slog.F("workspace_update", update),
1198 slog.F("update_kind", updateKind),
1199 )
1200 err = t.handleUpdate(update, updateKind)
1201 updateKind = Diff
1202 if err != nil {
1203 t.logger.Critical(context.Background(), "failed to handle workspace Update", slog.Error(err))
1204 cErr := t.client.Close()
1205 if cErr != nil {
1206 t.logger.Warn(context.Background(), "failed to close client", slog.Error(cErr))
1207 }
1208 select {
1209 case t.errChan <- err:
1210 default:
1211 }
1212 return
1213 }
1214 }
1215}
1216
1217type WorkspaceUpdate struct {
1218 UpsertedWorkspaces []*Workspace

Callers

nothing calls this directly

Calls 4

handleUpdateMethod · 0.95
RecvMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected