Beanstalkd -> Pheanstalk

This commit is contained in:
Juan Pablo Vial
2025-07-15 19:04:19 -04:00
parent 501151a90e
commit 79073ebeb7
20 changed files with 533 additions and 48 deletions

View File

@ -12,37 +12,11 @@ class Pending extends Console\Command\Command
parent::__construct($name);
}
protected function configure(): void
{
$this->addOption('full', 'f', Console\Input\InputOption::VALUE_NONE, 'Full output');
}
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
{
$jobs = $this->jobService->getPending();
$jobCount = count($jobs);
$jobCount = $this->jobService->getPending();
$output->writeln("Found {$jobCount} pending jobs");
if ($input->getOption('full') and $jobCount > 0) {
$io = new Console\Style\SymfonyStyle($input, $output);
$rows = [];
foreach ($jobs as $job) {
$retries = $job['retries'] ?? 0;
$updated = $job['updated_at'] ?? '';
$rows[] = [
$job['id'],
$job['created_at'],
$job['configuration']['type'],
$retries,
$updated
];
}
$io->table(['ID', 'Created', 'Type', 'Retries', 'Updated'], $rows);
}
return self::SUCCESS;
}
}

View File

@ -13,6 +13,7 @@ use Symfony\Component\Console;
class Run extends Console\Command\Command
{
public function __construct(protected Service\FastCGI $fastcgi, protected LoggerInterface $logger,
protected Service\Job $jobService,
protected DateTimeZone $timeZone, ?string $name = null)
{
parent::__construct($name);
@ -26,6 +27,11 @@ class Run extends Console\Command\Command
$now = new DateTimeImmutable();
}
if ($this->jobService->getPending() === 0) {
$output->writeln("[{$now->format('Y-m-d H:i:s e')}] No pending jobs to run.");
return self::SUCCESS;
}
$output->writeln("[{$now->format('Y-m-d H:i:s e')}] Running Ready Job...");
$this->runJob();
return $this->getResponses();

View File

@ -35,8 +35,13 @@ class Queue extends Command
];
$io = new Console\Style\SymfonyStyle($input, $this->sections['top']);
$now = new DateTimeImmutable('now', $this->timezone);
$io->title("[{$now->format('Y-m-d H:i:s e')}] Running Queue...");
if ($this->jobService->getPending() === 0) {
$io->success("[{$now->format('Y-m-d H:i:s e')}] Queue is empty");
return self::SUCCESS;
}
$io->title("[{$now->format('Y-m-d H:i:s e')}] Running Queue...");
return $this->runJob();
}