(event *wps.WaveEvent, newStatus string)
| 355 | } |
| 356 | |
| 357 | func handleRouteEvent(event *wps.WaveEvent, newStatus string) { |
| 358 | ctx := context.Background() |
| 359 | for _, scope := range event.Scopes { |
| 360 | if strings.HasPrefix(scope, "job:") { |
| 361 | jobId := strings.TrimPrefix(scope, "job:") |
| 362 | SetJobConnStatus(jobId, newStatus) |
| 363 | log.Printf("[job:%s] connection status changed to %s", jobId, newStatus) |
| 364 | |
| 365 | job, err := wstore.DBGet[*waveobj.Job](ctx, jobId) |
| 366 | if err != nil { |
| 367 | log.Printf("[job:%s] error getting job for status event: %v", jobId, err) |
| 368 | continue |
| 369 | } |
| 370 | sendBlockJobStatusEventByJob(ctx, job) |
| 371 | |
| 372 | if newStatus == JobConnStatus_Disconnected && job != nil && isJobManagerRunning(job) { |
| 373 | if shouldAttemptAutoReconnect(jobId) { |
| 374 | go attemptAutoReconnect(jobId, job.Connection) |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | func shouldAttemptAutoReconnect(jobId string) bool { |
| 382 | now := time.Now().Unix() |
no test coverage detected