Skip to content

Commit fb152cc

Browse files
authored
Merge pull request #11 from doppar/queue
readme file updated
2 parents 2c19e92 + 47f4472 commit fb152cc

File tree

1 file changed

+22
-147
lines changed

1 file changed

+22
-147
lines changed

README.md

Lines changed: 22 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,34 @@
1-
create a example job:
2-
```php
3-
<?php
1+
<p align="center">
2+
<a href="https://doppar.com" target="_blank">
3+
<img src="https://raw.githubusercontent.com/doppar/doppar/7138fb0e72cd55256769be6947df3ac48c300700/public/logo.png" width="400">
4+
</a>
5+
</p>
46

5-
namespace App\Jobs;
7+
<p align="center">
8+
<a href="https://github.com/doppar/queue/actions/workflows/tests.yml"><img src="https://github.com/doppar/queue/actions/workflows/tests.yml/badge.svg" alt="Build Status"></a>
9+
<a href="https://packagist.org/packages/doppar/queue"><img src="https://img.shields.io/packagist/dt/doppar/queue" alt="Total Downloads"></a>
10+
<a href="https://packagist.org/packages/doppar/queue"><img src="https://img.shields.io/packagist/v/doppar/queue" alt="Latest Stable Version"></a>
11+
<a href="https://github.com/doppar/queue/blob/main/LICENSE"><img src="https://img.shields.io/github/license/doppar/queue" alt="License"></a>
12+
</p>
613

7-
use Phaseolies\Support\Facades\Log;
8-
use Doppar\Queue\Job;
14+
## About Doppar Queue
915

10-
class SendEmailJob extends Job
11-
{
12-
/**
13-
* The number of times the job may be attempted.
14-
*
15-
* @var int
16-
*/
17-
public $tries = 3;
16+
> **Note:** This repository contains the core code of the Doppar framework queue package. If you want to build an application using Doppar, visit the main [Doppar repository](https://github.com/doppar/doppar).
1817
19-
/**
20-
* The number of seconds to wait before retrying.
21-
*
22-
* @var int
23-
*/
24-
public $retryAfter = 60;
18+
Doppar queue system offers robust features including multiple queue support for organizing jobs by priority or category, automatic retry logic with configurable attempts and delays, and comprehensive failed job tracking for easier debugging. It supports delayed execution for scheduling jobs in the future, graceful shutdown handling to safely stop workers, and built-in memory management that automatically restarts workers when limits are exceeded.
2519

26-
/**
27-
* The email data.
28-
*
29-
* @var array
30-
*/
31-
protected $emailData;
20+
## Contributing
3221

33-
/**
34-
* Create a new job instance.
35-
*
36-
* @param array $emailData
37-
*/
38-
public function __construct(array $emailData)
39-
{
40-
$this->emailData = $emailData;
41-
}
22+
Thank you for considering contributing to the Doppar framework! The contribution guide can be found in the [Doppar documentation](https://doppar.com/versions/3.x/contributions.html).
4223

43-
/**
44-
* Execute the job.
45-
*
46-
* @return void
47-
*/
48-
public function handle(): void
49-
{
50-
// Your email sending logic here
51-
$to = $this->emailData['to'];
52-
$subject = $this->emailData['subject'];
53-
$message = $this->emailData['message'];
24+
## Code of Conduct
5425

55-
Log::info("Email sent successfully to {$to}");
56-
}
26+
In order to ensure that the Doppar community is welcoming to all, please review and abide by the [Code of Conduct](https://doppar.com/versions/3.x/contributions.html#code-of-conduct).
5727

58-
/**
59-
* Handle a job failure.
60-
*
61-
* @param \Throwable $exception
62-
* @return void
63-
*/
64-
public function failed(\Throwable $exception): void
65-
{
66-
// Send notification to admin about failed email
67-
Log::error("Failed to send email after {$this->tries} attempts", [
68-
'email_to' => $this->emailData['to'],
69-
'exception' => $exception->getMessage(),
70-
]);
28+
## Security Vulnerabilities
7129

72-
// You could send a notification to admins here
73-
}
74-
}
75-
```
30+
Please review [our security policy](https://github.com/doppar/framework/security/policy) on how to report security vulnerabilities.
7631

77-
example controller
78-
```
79-
<?php
80-
81-
namespace App\Http\Controllers;
82-
83-
use Phaseolies\Utilities\Attributes\Route;
84-
use Doppar\Queue\Facades\Queue;
85-
use App\Jobs\SendEmailJob;
86-
use App\Http\Controllers\Controller;
87-
88-
class QueueController extends Controller
89-
{
90-
#[Route('queue')]
91-
public function queue()
92-
{
93-
$job = new SendEmailJob([
94-
'to' => '[email protected]',
95-
'subject' => 'Welcome!',
96-
'message' => 'Thanks for signing up!',
97-
]);
98-
99-
$jobId = Queue::push($job);
100-
101-
echo "Job dispatched with ID: {$jobId}\n";
102-
103-
// with specific name
104-
$job = new SendEmailJob([
105-
'to' => '[email protected]',
106-
'subject' => 'Welcome!',
107-
'message' => 'Thanks for signing up!',
108-
])->onQueue('emails')
109-
->delayFor(10);
110-
111-
// command will be [php pool queue:run --queue=emails]
112-
113-
$jobId = Queue::push($job);
114-
}
115-
}
116-
```
117-
118-
then add provider in your `config/app.php`
119-
```php
120-
\Doppar\Queue\QueueServiceProvider::class
121-
```
122-
123-
Run
124-
```php
125-
php pool vendor:publish --provider="Doppar\Queue\QueueServiceProvider"
126-
// now migrate
127-
php pool migrate
128-
```
129-
130-
Then run
131-
```bash
132-
php pool queue:run
133-
134-
# Specify only the queue name
135-
php pool queue:run --queue=emails
136-
php pool queue:run --queue=notifications
137-
php pool queue:run --queue=reports
138-
139-
# Change sleep time between jobs
140-
php pool queue:run --sleep=1
141-
php pool queue:run --sleep=5
142-
php pool queue:run --queue=emails --sleep=10
143-
144-
# Adjust memory limit
145-
php pool queue:run --memory=256
146-
php pool queue:run --memory=512 --queue=emails
147-
php pool queue:run --memory=1024 --sleep=2
148-
149-
# Adjust timeout (max execution time in seconds)
150-
php pool queue:run --timeout=600
151-
php pool queue:run --timeout=1800 --queue=emails
152-
php pool queue:run --timeout=7200 --memory=512
153-
154-
# Combine all options (custom configuration)
155-
php pool queue:run --queue=emails --sleep=5 --memory=256 --timeout=900
156-
php pool queue:run --queue=notifications --sleep=3 --memory=512 --timeout=1800
157-
php pool queue:run --queue=reports --sleep=10 --memory=1024 --timeout=3600
158-
```
32+
## License
15933

34+
The Doppar framework is open-sourced software licensed under the [MIT license](LICENSE.md).

0 commit comments

Comments
 (0)