Skip to content

Commit

Permalink
Allow calls of pushDelayed without max delay specified (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-vasicek authored Oct 31, 2024
1 parent acd53c9 commit f5282e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/Queue/AWSSQS/SqsQueueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ public function pushDelayedWithMilliseconds(JobInterface $job, int $delayInMilli
* implementation of automated tests & synthetic monitoring of delayed job
* scheduler on live environments while maintaining quick feedback loop.
*/
public function pushDelayed(JobInterface $job, int $delayInSeconds, int $maxDelayInSeconds = self::MAX_DELAY_IN_SECONDS): void
public function pushDelayed(JobInterface $job, int $delayInSeconds, ?int $maxDelayInSeconds = self::MAX_DELAY_IN_SECONDS): void
{
assert(
$maxDelayInSeconds >= 0,
'Argument $maxDelayInSeconds must be greater or equal to 0',
$maxDelayInSeconds === null || $maxDelayInSeconds >= 0,
'If argument $maxDelayInSeconds is specified, it must be greater or equal to 0',
);

$prefixedQueueName = $this->getPrefixedQueueName($job->getJobDefinition()->getQueueName());
Expand All @@ -272,6 +272,12 @@ public function pushDelayed(JobInterface $job, int $delayInSeconds, int $maxDela

$finalDelayInSeconds = $delayInSeconds;

if ($maxDelayInSeconds === null) {
$this->planExecutionUsingSqsDeliveryDelay($job, $prefixedQueueName, $delayInSeconds, $finalDelayInSeconds);

return;
}

if ($delayInSeconds > $maxDelayInSeconds) {
if ($this->delayedJobScheduler !== null) {
$this->scheduleJob($job, $prefixedQueueName, $executionPlannedAt, $delayInSeconds, $maxDelayInSeconds);
Expand Down
2 changes: 1 addition & 1 deletion src/Queue/QueueManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function push(JobInterface $job): void;
* implementation of automated tests & synthetic monitoring of delayed job
* scheduler on live environments while maintaining quick feedback loop.
*/
public function pushDelayed(JobInterface $job, int $delayInSeconds, int $maxDelayInSeconds): void;
public function pushDelayed(JobInterface $job, int $delayInSeconds, ?int $maxDelayInSeconds = null): void;


public function pushDelayedWithMilliseconds(JobInterface $job, int $delayInMilliseconds): void;
Expand Down

0 comments on commit f5282e4

Please sign in to comment.