4
4
[ ![ Total Downloads] ( http://poser.pugx.org/shipsaas/laravel-priority-queue/downloads )] ( https://packagist.org/packages/shipsaas/laravel-priority-queue )
5
5
[ ![ codecov] ( https://codecov.io/gh/shipsaas/laravel-priority-queue/branch/main/graph/badge.svg?token=V3HOOR12HA )] ( https://codecov.io/gh/shipsaas/laravel-priority-queue )
6
6
[ ![ Build & Test] ( https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build.yml/badge.svg )] ( https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build.yml )
7
- [ ![ Build & Test (Laravel 9, 10 )] ( https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build-laravel.yml/badge.svg )] ( https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build-laravel.yml )
7
+ [ ![ Build & Test (Laravel 10, 11 )] ( https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build-laravel.yml/badge.svg )] ( https://github.com/shipsaas/laravel-priority-queue/actions/workflows/build-laravel.yml )
8
8
9
- A simple Priority Queue Driver for your Laravel Applications.
9
+ A simple Priority Queue Driver for your Laravel Applications to serve your priority messages and
10
+ makes users happy 🔋.
10
11
11
- Laravel Priority Queue Driver uses the ` database ` driver.
12
+ With the famous Repository Pattern of Laravel, Priority Queue Driver is easily get injected into
13
+ Laravel's Lifecycle without any hassle/hurdle.
14
+
15
+ We can use built-in artisan command ` php artisan queue:work ` 😎.
12
16
13
17
## Supports
14
- - Laravel 10 (compatible by default)
15
- - Laravel 9 (supports until Laravel drops the bug fixes at [ August 8th, 2023] ( https://laravel.com/docs/10.x/releases ) )
16
- - PHP 8.1+
18
+ - Laravel 11 (supports by default)
19
+ - Laravel 10 (supports until Laravel drops the bug fixes at [ August 6th, 2024] ( https://laravel.com/docs/11.x/releases ) )
20
+ - PHP 8.2 & 8.3
21
+ - Any database that Laravel supported.
17
22
18
- ## Architecture
23
+ ## Architecture Diagram
19
24
20
25
![ Seth Phat - Laravel Priority Queue] ( https://i.imgur.com/H8OEMhQ.png )
21
26
22
- ## Why ` database ` ?
23
-
24
- - Easy and simple to implement.
25
- - Utilize the ` ORDER BY ` and ` INDEX ` for fast queue msgs pop process.
26
- - Super visibility (you can view the jobs and their data in DB).
27
- - Super flexibility (you can change the weight directly in DB to unblock important msgs).
27
+ ### Why Priority Queue Driver use Database?
28
28
29
- ## Installation
29
+ - Everybody knows Database (MySQL, PgSQL, etc) 👀.
30
+ - Easy and simple to implement ❤️.
31
+ - Utilize the ` ORDER BY ` and ` INDEX ` for fast queue msgs pop process. Faster than any other stuff 🔥.
32
+ - Highest visibility (you can view the jobs and their data in DB) ⭐️.
33
+ - Highest flexibility (you can change the weight directly in DB to unblock important msgs) 💰.
34
+ - No extra tool involved. Just Laravel 🥰.
30
35
31
- Install the library:
36
+ ## Install Laravel Priority Queue
32
37
33
38
``` bash
34
39
composer require shipsaas/laravel-priority-queue
35
40
```
36
41
37
- Export and run the migration:
42
+ ### One-Time Setup
43
+
44
+ Export and run the migration (one-time):
38
45
39
46
``` bash
47
+ # if you don't need to adjust the migration, don't have to export it
40
48
php artisan vendor:publish --tag=priority-queue-migrations
41
49
php artisan migrate
42
50
```
43
51
44
- ### One-Time Setup
45
-
46
52
Open ` config/queue.php ` and add this into the ` connections ` array:
47
53
48
54
``` php
55
+ 'connections' => [
56
+ // ... a lot of connections above
57
+ // then our lovely guy here
49
58
'database-priority' => [
50
59
'driver' => 'database-priority',
51
60
'connection' => 'mysql',
52
61
'table' => 'priority_jobs',
53
62
'queue' => 'default',
54
63
'retry_after' => 90,
55
64
],
65
+ ],
56
66
```
57
67
58
- ### Note
68
+ ## Scale/Reliability Consideration
59
69
60
- We highly recommend you to use a different database connection (eg ` mysql_secondary ` ) to avoid the worker processes ramming your
70
+ It is recommended using a different database connection (eg ` mysql_secondary ` ) to avoid the worker processes ramming your
61
71
primary database.
62
72
63
73
## Usage
@@ -86,7 +96,7 @@ class SendEmail implements ShouldQueue
86
96
87
97
public function getJobWeight() : int
88
98
{
89
- return $this->user->isPro ()
99
+ return $this->user->isUsingProPlan ()
90
100
? 1000
91
101
: 500;
92
102
}
@@ -111,10 +121,12 @@ Queue::connection('database-priority')
111
121
112
122
## Run The Queue Worker
113
123
114
- Nothing different from the Laravel's Doc .
124
+ Nothing different from the Laravel Documentation 😎. Just need to include the ` database-priority ` driver .
115
125
116
126
``` bash
117
127
php artisan queue:work database-priority
128
+
129
+ # Extra win, priority on topic
118
130
php artisan queue:work database-priority --queue=custom
119
131
```
120
132
0 commit comments