-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[12.x] Clean up queue pausing #57863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 12.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
| namespace Illuminate\Queue\Console\Concerns; | ||
|
|
||
| trait ParsesQueue | ||
| { | ||
| /** | ||
| * Parse the queue argument into connection and queue name. | ||
| * | ||
| * @param string $queue | ||
| * @return array{string, string} | ||
| */ | ||
| protected function parseQueue($queue) | ||
| { | ||
| [$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null); | ||
|
|
||
| return isset($queue) | ||
| ? [$connection, $queue] | ||
| : [$this->laravel['config']['queue.default'], $connection]; | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,11 +4,14 @@ | |
|
|
||
| use Illuminate\Console\Command; | ||
| use Illuminate\Contracts\Queue\Factory as QueueManager; | ||
| use Illuminate\Queue\Console\Concerns\ParsesQueue; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
|
|
||
| #[AsCommand(name: 'queue:resume')] | ||
| #[AsCommand(name: 'queue:resume', aliases: ['queue:continue'])] | ||
| class ResumeCommand extends Command | ||
| { | ||
| use ParsesQueue; | ||
|
|
||
| /** | ||
| * The console command name. | ||
| * | ||
|
|
@@ -17,57 +20,32 @@ class ResumeCommand extends Command | |
| protected $signature = 'queue:resume {queue : The name of the queue that should resume processing}'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * The console command name aliases. | ||
| * | ||
| * @var string | ||
| * @var list<string> | ||
| */ | ||
| protected $description = 'Resume job processing for a paused queue'; | ||
| protected $aliases = ['queue:continue']; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is two command with same names realy needed? here was just renaming one command to other. d8cbad4
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good call, thanks for linking to the commit. @taylorotwell let me know if you want me to keep ResumeCommand or ContinueCommand. |
||
|
|
||
| /** | ||
| * The queue manager instance. | ||
| * The console command description. | ||
| * | ||
| * @var \Illuminate\Contracts\Queue\Factory | ||
| */ | ||
| protected $manager; | ||
|
|
||
| /** | ||
| * Create a new queue resume command. | ||
| * @var string | ||
| */ | ||
| public function __construct(QueueManager $manager) | ||
| { | ||
| parent::__construct(); | ||
|
|
||
| $this->manager = $manager; | ||
| } | ||
| protected $description = 'Resume job processing for a paused queue'; | ||
|
|
||
| /** | ||
| * Execute the console command. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function handle() | ||
| public function handle(QueueManager $manager) | ||
| { | ||
| [$connection, $queue] = $this->parseQueue($this->argument('queue')); | ||
|
|
||
| $this->manager->resume($connection, $queue); | ||
| $manager->resume($connection, $queue); | ||
|
|
||
| $this->components->info("Job processing on queue [{$connection}:{$queue}] has been resumed."); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * Parse the queue argument into connection and queue name. | ||
| * | ||
| * @param string $queue | ||
| * @return array | ||
| */ | ||
| protected function parseQueue($queue) | ||
| { | ||
| [$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null); | ||
|
|
||
| return isset($queue) | ||
| ? [$connection, $queue] | ||
| : [$this->laravel['config']['queue.default'], $connection]; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the following?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong feeling about one being better than the other. I was just hoping to move this to a trait to avoid drift between the commands.