MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / cleanupTask

Method cleanupTask

cmd/cql-proxy/task/task.go:310–351  ·  view source on GitHub ↗
(t *taskItem)

Source from the content-addressed store, hash-verified

308}
309
310func (m *Manager) cleanupTask(t *taskItem) {
311 // collect result and save to database
312 now := time.Now().Unix()
313 t.task.Finished = now
314 t.task.Updated = now
315 t.task.Result = t.result
316
317 if t.err != nil {
318 t.task.State = model.TaskFailed
319 t.task.Result = gin.H{
320 "error": t.err.Error(),
321 "result": t.task.Result,
322 }
323 } else {
324 t.task.State = model.TaskSuccess
325 }
326
327 err := model.UpdateTask(m.db, t.task)
328 if err != nil {
329 return
330 }
331
332 log.Debugf("task cleanup: %v", t.task.LogData())
333
334 // trigger wait
335 if waits, ok := m.waitMap[t.task.ID]; ok {
336 // trigger waits
337 for _, w := range waits {
338 if w.ch != nil {
339 select {
340 case <-w.ch:
341 default:
342 close(w.ch)
343 }
344 }
345 }
346
347 delete(m.waitMap, t.task.ID)
348 }
349
350 delete(m.taskMap, t.task.ID)
351}

Callers 2

StopMethod · 0.95
runMethod · 0.95

Calls 4

UpdateTaskFunction · 0.92
DebugfFunction · 0.92
ErrorMethod · 0.80
LogDataMethod · 0.80

Tested by

no test coverage detected