()
| 1179 | } |
| 1180 | |
| 1181 | func (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 | |
| 1217 | type WorkspaceUpdate struct { |
| 1218 | UpsertedWorkspaces []*Workspace |
nothing calls this directly
no test coverage detected