for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Lamoda\QueueBundle\Service;
use DateTime;
use Lamoda\QueueBundle\Entity\QueueEntityInterface;
class DelayService
{
/**
* @var ResolverStrategyService
*/
protected $strategyService;
public function __construct(ResolverStrategyService $strategyService)
$this->strategyService = $strategyService;
}
public function delayQueue(QueueEntityInterface $queue): QueueEntityInterface
$strategy = $this->strategyService->getStrategy($queue->getName());
$iteration = $queue->getAttempts() ?? 1;
$newDelayInterval = $strategy->generateInterval($iteration);
$delayUntil = $this->getStartDateTime()->add($newDelayInterval);
$queue->setWaiting($delayUntil);
return $queue;
protected function getStartDateTime(): DateTime
return new DateTime();