Skip to content

Commit

Permalink
feat(Console): Add ability to change queue for queued commands
Browse files Browse the repository at this point in the history
BREAKING CHANGE: minor impact, scheduleServiceContract contains new parameter `string $queue = 'default'`
  • Loading branch information
pionl committed Nov 24, 2022
1 parent fe85151 commit b5852d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/Console/Contracts/ScheduleServiceContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ public function command(string $command, array $parameters = []): Event;
* Use for long tasks - ensurers that the command is unique.
*
* @param string $command Command signature or class
* @param array $keyedParameters You need to key the parameters by command signature
* @param array<string, string|float|int|bool> $keyedParameters You need to key the parameters by command signature
*/
public function queueCommand(string $command, array $keyedParameters = [], int $uniqueFor = 1800): CallbackEvent;
public function queueCommand(
string $command,
array $keyedParameters = [],
int $uniqueFor = 1800,
string $queue = 'default'
): CallbackEvent;

/**
* Add a new job callback event to the schedule. Must set $job->queue.
Expand Down
12 changes: 9 additions & 3 deletions src/Console/Services/ScheduleServiceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ public function command(string $command, array $parameters = []): Event
* Use for long tasks - ensurers that the command is unique.
*
* @param string $command Command signature or class
* @param array $keyedParameters You need to key the parameters by command signature
* @param array<string, string|float|int|bool> $keyedParameters You need to key the parameters by command signature
*/
public function queueCommand(string $command, array $keyedParameters = [], int $uniqueFor = 1800): CallbackEvent
{
public function queueCommand(
string $command,
array $keyedParameters = [],
int $uniqueFor = 1800,
string $queue = 'default'
): CallbackEvent {
$job = new CommandInQueueJob($command, $keyedParameters, $uniqueFor);
$job->queue = $queue;

$event = $this->schedule->job($job);

// Ensure that php artisan schedule:list will return correct data
Expand Down

0 comments on commit b5852d7

Please sign in to comment.