MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / handleBlockCloseEvent

Function handleBlockCloseEvent

pkg/jobcontroller/jobcontroller.go:457–482  ·  view source on GitHub ↗
(event *wps.WaveEvent)

Source from the content-addressed store, hash-verified

455}
456
457func 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
484func onConnectionUp(connName string) {
485 log.Printf("[conn:%s] connection became connected, reconnecting jobs", connName)

Callers

nothing calls this directly

Calls 2

WithTxRtnFunction · 0.92
TerminateAndDetachJobFunction · 0.85

Tested by

no test coverage detected