(event *wps.WaveEvent)
| 455 | } |
| 456 | |
| 457 | func handleBlockCloseEvent(event *wps.WaveEvent) { |
| 458 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
| 459 | defer cancelFn() |
| 460 | blockId, ok := event.Data.(string) |
| 461 | if !ok { |
| 462 | log.Printf("[blockclose] invalid event data type") |
| 463 | return |
| 464 | } |
| 465 | |
| 466 | jobIds, err := wstore.WithTxRtn(ctx, func(tx *wstore.TxWrap) ([]string, error) { |
| 467 | query := `SELECT oid FROM db_job WHERE json_extract(data, '$.attachedblockid') = ?` |
| 468 | jobIds := tx.SelectStrings(query, blockId) |
| 469 | return jobIds, nil |
| 470 | }) |
| 471 | if err != nil { |
| 472 | log.Printf("[block:%s] error looking up jobids: %v", blockId, err) |
| 473 | return |
| 474 | } |
| 475 | if len(jobIds) == 0 { |
| 476 | return |
| 477 | } |
| 478 | |
| 479 | for _, jobId := range jobIds { |
| 480 | TerminateAndDetachJob(ctx, jobId) |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | func onConnectionUp(connName string) { |
| 485 | log.Printf("[conn:%s] connection became connected, reconnecting jobs", connName) |
nothing calls this directly
no test coverage detected