UpdateProgress updates the progress of the current task.
(processed int)
| 100 | |
| 101 | // UpdateProgress updates the progress of the current task. |
| 102 | func (s *TaskService) UpdateProgress(processed int) error { |
| 103 | status, err := s.GetTaskStatus() |
| 104 | if err != nil { |
| 105 | return err |
| 106 | } |
| 107 | if !status.IsRunning { |
| 108 | return nil |
| 109 | } |
| 110 | |
| 111 | status.Processed = processed |
| 112 | statusBytes, err := json.Marshal(status) |
| 113 | if err != nil { |
| 114 | return fmt.Errorf("failed to serialize updated status: %w", err) |
| 115 | } |
| 116 | |
| 117 | return s.store.Set(globalTaskKey, statusBytes, ResultTTL) |
| 118 | } |
| 119 | |
| 120 | // EndTask marks the current task as finished and stores its final result. |
| 121 | func (s *TaskService) EndTask(resultData any, taskErr error) error { |
no test coverage detected