// Dequeue dequeues a Job which doesn't have have another Executing Job
// for the same Cid. Saying it differently, it's safe to execute. The returned
// job Status is automatically changed to Executing. If no jobs are available to dequeue
// it returns a nil *ffs.Job and no-error.
Dequeue dequeues a Job which doesn't have have another Executing Job
for the same Cid. Saying it differently, it's safe to execute. The returned
job Status is automatically changed to Executing. If no jobs are available to dequeue
it returns a nil *ffs.Job and no-error.
// Dequeue dequeues a Job which doesn ' t have have another Executing Job // for the same Cid . Saying it differently it ' s safe to execute . The returned // job Status is automatically changed to Executing . If no jobs are available to dequeue // it returns a nil * ffs . Job and no - error .
func (s *Store) Dequeue() (*ffs.StorageJob, error) {
	s.lock.Lock()
	defer s.lock.Unlock()
	for _, job := range s.queued {
		execJob, ok := s.executingJobs[job.APIID][job.Cid]
		if job.Status == ffs.Queued && !ok {
			job.Status = ffs.Executing
			if err := s.put(job); err != nil {
				return nil, err
			}
			return &job, nil
		}
		log.Infof("queued %s is delayed since job %s is running", job.ID, execJob.ID)
	}
	return nil, nil
}
func ( s * Store ) Dequeue ( ) ( * ffs . StorageJob , error ) { s . lock . Lock ( ) defer s . lock . Unlock ( ) for _ , job := range s . queued { execJob , ok := s . executingJobs [ job . APIID ] [ job . Cid ] if job . Status == ffs . Queued && ! ok { job . Status = ffs . Executing if err := s . put ( job ) ; err != nil { return nil , err } return & job , nil } log . Infof ( " " , job . ID , execJob . ID ) } return nil , nil }
Dequeue dequeues a Job which doesn't have have another Executing Job
for the same Cid.
Dequeue dequeues a Job which doesn ' t have have another Executing Job for the same Cid .