New pushes new task to scheduling pool.
(tt model.TaskType, developer int64, account int64, args gin.H)
| 142 | |
| 143 | // New pushes new task to scheduling pool. |
| 144 | func (m *Manager) New(tt model.TaskType, developer int64, account int64, args gin.H) (id int64, err error) { |
| 145 | t, err := model.NewTask(m.db, tt, developer, account, args) |
| 146 | if err != nil { |
| 147 | err = errors.Wrapf(err, "new task failed") |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | id = t.ID |
| 152 | |
| 153 | select { |
| 154 | case m.newCh <- t: |
| 155 | log.Debugf("created new task: %v", t.LogData()) |
| 156 | case <-m.ctx.Done(): |
| 157 | t.Result = gin.H{ |
| 158 | "error": m.ctx.Err(), |
| 159 | } |
| 160 | _ = model.UpdateTask(m.db, t) |
| 161 | } |
| 162 | |
| 163 | return |
| 164 | } |
| 165 | |
| 166 | // Register register new handle for specified task type to run. |
| 167 | func (m *Manager) Register(tt model.TaskType, f HandleFunc) { |
nothing calls this directly
no test coverage detected