MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / QueueTask

Method QueueTask

pkg/queue/queue.go:184–209  ·  view source on GitHub ↗

QueueTask to queue single Task

(ctx context.Context, t Task)

Source from the content-addressed store, hash-verified

182
183// QueueTask to queue single Task
184func (q *queue) QueueTask(ctx context.Context, t Task) error {
185 if atomic.LoadInt32(&q.stopFlag) == 1 {
186 return ErrQueueShutdown
187 }
188
189 if t.Status() != task.StatusSuspending {
190 q.metric.IncSubmittedTask()
191 if err := q.transitStatus(ctx, t, task.StatusQueued); err != nil {
192 return err
193 }
194 }
195
196 if err := q.scheduler.Queue(t); err != nil {
197 return err
198 }
199 owner := ""
200 if t.Owner() != nil {
201 owner = t.Owner().Email
202 }
203 q.logger.Info("New Task with type %q submitted to queue %q by %q", t.Type(), q.name, owner)
204 if q.registry != nil {
205 q.registry.Set(t.ID(), t)
206 }
207
208 return nil
209}
210
211// newContext creates a new context for a new Task iteration.
212func (q *queue) newContext(t Task) context.Context {

Callers 1

StartMethod · 0.95

Calls 9

transitStatusMethod · 0.95
StatusMethod · 0.65
IncSubmittedTaskMethod · 0.65
QueueMethod · 0.65
OwnerMethod · 0.65
InfoMethod · 0.65
TypeMethod · 0.65
SetMethod · 0.65
IDMethod · 0.65

Tested by

no test coverage detected