-
Notifications
You must be signed in to change notification settings - Fork 658
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
[5.x] Add ability to clear queues from dashboard #890
Conversation
It would probably be best to check for the existence of |
Sure @taylorotwell, I think an even better way might be to check if the queue has the method |
Sure, either way. |
@taylorotwell, I've added the check in the UI to display only if the |
return $this->getRecent($index === 0 ? null : $index * 50)->filter(function ($recent) use ($queue) { | ||
return in_array($recent->status, ['pending', 'reserved']) && $recent->queue === $queue; | ||
}); | ||
})->flatten(1)->pluck('id')->all(); |
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.
Please explain what this is doing.
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.
Here we're collecting the IDs of the pending or reserved jobs on the specified queue. To do so, we get all the recent jobs (50 at a time based on the in-built RedisJobRepository methods) and filter through them to check 1) if they're either pending or reserved and 2) if the queue matches the specified queue. On the filtered set of jobs, we pluck the job IDs and then delete them from the Redis hash and recent/pending jobs sorted sets.
@@ -5,6 +5,7 @@ | |||
Route::prefix('api')->group(function () { | |||
// Dashboard Routes... | |||
Route::get('/stats', 'DashboardStatsController@index')->name('horizon.stats.index'); | |||
Route::post('/clearQueue', 'QueueClearController')->name('horizon.queue-clear.store'); |
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.
Unclear to me why a delete operation would be a POST. Shouldn't it be something like DELETE /queues/{queue-name} or something?
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 thought of clearing queues as more of an action rather than deleting a resource. If you'd like I can change it to a delete operation.
Why don't we take this one step at a time. Why don't we have just a CLI command to clear queues in Horizon first. |
This PR adds the ability to clear queues (delete all jobs from specific queues) from the Horizon dashboard.
Resubmission of #742 with fixes to sorted sets and also uses the in-built queue clear of the Laravel framework based on laravel/framework#34330. Fixes #328.
Important Notice
Clearing of queues will not work on Laravel versions below 8.4 (unreleased). So I'm not sure if we want to send to master or 5x? The
illuminate\queue
repository isn't updated with the recent changes either, so we can't bump up that version yet. Also, I haven't compiled assets with this PR. Let me know if you'd like me to update with compilation of assets as well.