Пример #1
0
 /**
  * @param string $queueId
  * @param JobStatus $status
  * @return Keyspace\JobList[]
  */
 public function jobsWithStatus($queueId, JobStatus $status)
 {
     switch (true) {
         case $status->equals(JobStatus::pending()):
             return $this->pendingJobs($queueId);
         case $status->equals(JobStatus::processing()):
             return $this->processingJobs($queueId);
         case $status->equals(JobStatus::successful()):
             return $this->successfulJobs($queueId);
         case $status->equals(JobStatus::failed()):
             return $this->failedJobs($queueId);
     }
 }
Пример #2
0
 public function getPendingAction($queueId)
 {
     $jobs = $this->metro->listJobs($queueId, JobStatus::pending(), 20, 1);
     $responseContent = [];
     $responseContent['data'][] = ['type' => 'job'];
     return new JsonResponse($responseContent);
 }
Пример #3
0
 private function _list(array $jobIds, JobStatus $status)
 {
     switch (true) {
         case $status->equals(JobStatus::pending()):
             $needle = 'queued';
             break;
         case $status->equals(JobStatus::processing()):
             $needle = 'processing';
             break;
         default:
             return $jobIds;
     }
     $list = [];
     foreach ($jobIds as $jobId) {
         if ($lastEvent = $this->keyspace->jobHistory($jobId)->lastEvent($needle)) {
             $timestamp = (new \DateTime($lastEvent->dateTime()))->getTimestamp();
             $list[$jobId] = $timestamp;
         }
     }
     return $list;
 }
Пример #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $metro = $this->metro;
     $id = $input->getArgument('id');
     $filter = $input->getOption('filter');
     if ($job = $metro->getJob($id)) {
         $job = $job->toArray();
         $job['history'] = $metro->getHistory($id);
         $output->writeln($this->encode($job, $filter));
         return 0;
     }
     if (in_array($id, $metro->listQueues())) {
         $queue = [];
         $queue['id'] = $id;
         foreach (JobStatus::all() as $status) {
             $queue[$status->value()] = $metro->countJobs($id, $status);
         }
         $output->writeln($this->encode($queue, $filter));
         return 0;
     }
     return 1;
 }
Пример #5
0
 protected function status()
 {
     return JobStatus::failed();
 }
Пример #6
0
 protected function status()
 {
     return JobStatus::successful();
 }
Пример #7
0
 protected function status()
 {
     return JobStatus::processing();
 }
Пример #8
0
 protected function status()
 {
     return JobStatus::pending();
 }
Пример #9
0
 function it_knows_how_many_jobs_have_succeeded(Redis $redis)
 {
     $redis->zcard('queue:my-queue:succeeded')->willReturn(5);
     $this->countJobs('my-queue', JobStatus::successful())->shouldReturn(5);
 }