snapshot returns a point-in-time copy of the fields needed to render a response, so callers never touch the mutex directly.
()
| 148 | // snapshot returns a point-in-time copy of the fields needed to render a |
| 149 | // response, so callers never touch the mutex directly. |
| 150 | func (t *TaskProgressInfo) snapshot() (status TaskStatus, total, downloaded int64, totalFiles, downloadedFiles int, startedAt time.Time, err string, updatedAt time.Time) { |
| 151 | t.mu.Lock() |
| 152 | defer t.mu.Unlock() |
| 153 | return t.Status, t.TotalBytes, t.DownloadedBytes, t.TotalFiles, t.DownloadedFiles, t.StartedAt, t.Error, t.UpdatedAt |
| 154 | } |
| 155 | |
| 156 | // Emit implements taskevent.Sink. It translates task lifecycle events into |
| 157 | // status/progress updates and fires the webhook on terminal transitions. |
no outgoing calls