public function applyTo(Recruiter\Worker $worker) { if ($this->label !== 'all') { $worker->workOnJobsGroupedAs($this->label); } return $worker; }
/** * @step * @return integer how many jobs were unlocked as a result */ public function retireDeadWorkers(Clock $clock, Interval $consideredDeadAfter) { return $this->jobs->releaseAll($jobsAssignedToDeadWorkers = Worker::retireDeadWorkers($this->workers, $clock, $consideredDeadAfter)); }
public static function pickReadyJobsForWorkers(MongoCollection $collection, $worksOn, $workers) { $jobs = Onebip\array_pluck(iterator_to_array($collection->find(Worker::canWorkOnAnyJobs($worksOn) ? ['scheduled_at' => ['$lt' => T\MongoDate::now()], 'locked' => false] : ['scheduled_at' => ['$lt' => T\MongoDate::now()], 'locked' => false, 'group' => $worksOn], ['_id' => 1])->sort(['scheduled_at' => 1])->limit(count($workers))), '_id'); if (count($jobs) > 0) { return [$worksOn, $workers, $jobs]; } }