Skip to content

Commit c3207e2

Browse files
committed
docs update
1 parent 8aa33e1 commit c3207e2

6 files changed

Lines changed: 33 additions & 15 deletions

File tree

docs/basic_usage.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,37 @@ class Email extends BaseJob implements JobInterface
7373
}
7474
```
7575

76-
The method that handles the job is the `process` method. It is the one that is called when our job is executed.
76+
To handles the job we always use the `process` method. This method is called when our job is executed.
7777

7878
You may be wondering what the `$this->data['message']` variable is all about. We'll explain that in detail in the next section, but for now it's important for you to remember that all the variables we pass to the Job class are always held in the `$this->data` variable.
7979

8080
Throwing an exception is a way to let the queue worker know that the job has failed.
8181

82+
We can also configure some things on the job level. It's a number of tries, when the job is failing and time after the job will be retried again after failure. We can specify these options by using variables:
83+
84+
```php
85+
// ...
86+
87+
class Email extends BaseJob implements JobInterface
88+
{
89+
protected int $retryAfter = 60;
90+
protected int $tries = 1;
91+
92+
// ...
93+
94+
}
95+
```
96+
97+
Values presented above, are the default one. So you need to add them only when you want to change them.
98+
99+
These variables may be overwritten by the queue worker, if we use the proper parameters with command `queue:work`. For more information, see [commands](commands.md).
100+
82101
### Sending job to the queue
83102

84103
Sending a task to the queue is very simple and comes down to one command:
85104

86105
```php
87-
service('queue')->push('QueueName', 'jobName', ['array' => 'parameters']);
106+
service('queue')->push('queueName', 'jobName', ['array' => 'parameters']);
88107
```
89108

90109
In our particular case, for the `Email` class, it might look like this:

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Allows you to consume jobs from a specific queue.
5959
* `-rest` - Rest time between the jobs in the queue. Default value: `0` (seconds)
6060
* `-max-jobs` - The maximum number of jobs to handle before worker should exit. Disabled by default.
6161
* `-max-time` - The maximum number of seconds worker should run. Disabled by default.
62-
* `-memory` - The maximum memory in MB that worker can take. Default value: `128`,
62+
* `-memory` - The maximum memory in MB that worker can take. Default value: `128`.
6363
* `-tries` - The number of attempts after which the job will be considered as failed. Overrides settings from the Job class. Disabled by default.
6464
* `-retry-after` - The number of seconds after which the job is to be restarted in case of failure. Overrides settings from the Job class. Disabled by default.
6565
* `--stop-when-empty` - Stop when the queue is empty.

docs/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
A library that helps you handle Queues in the CodeIgniter 4 framework.
44

55
Add job to the queue.
6+
67
```php
7-
service('queue')->push('QueueName', 'jobName', ['array' => 'parameters']);
8+
service('queue')->push('queueName', 'jobName', ['array' => 'parameters']);
89
```
910

10-
Listen for queue jobs.
11+
Listen for queued jobs.
1112

12-
php spark queue:work QueueName
13+
php spark queue:work queueName
1314

1415
### Requirements
1516

docs/installation.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
- [Composer Installation](#composer-installation)
44
- [Manual Installation](#manual-installation)
5-
- [Database migration](#database-migration)
5+
- [Database Migration](#database-migration)
66

77
## Composer Installation
88

99
The only thing you have to do is to run this command, and you're ready to go.
1010

11-
```console
12-
composer require michalsn/codeigniter-queue
13-
```
11+
composer require michalsn/codeigniter-queue
1412

1513
## Manual Installation
1614

@@ -32,12 +30,10 @@ public $psr4 = [
3230
// ...
3331
```
3432

35-
## Database migration
33+
## Database Migration
3634

3735
Regardless of which installation method you chose, we also need to migrate the database to add new tables.
3836

3937
You can do this with the following command:
4038

41-
```console
42-
php spark migrate --all
43-
```
39+
php spark migrate --all

docs/running_queues.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ We could think about resigning with `-max-jobs` parameter, but it can have unpre
2626

2727
So choosing the right command is not so obvious. We have to estimate how many jobs we will have in the queue and decide how crucial it is to empty the queue as soon as possible.
2828

29+
You might use CodeIgniter [Tasks](https://github.com/codeigniter4/tasks) library to schedule queue worker instead of working directly with CRON.
30+
2931
### Running many instances of the same queue
3032

3133
As mentioned above, sometimes we may want to have multiple instances of the same command running at the same time. The queue is safe to use in that scenario with all databases except `SQLite3` since it doesn't guarantee that the job will be selected only by one process.

docs/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
If you want to assign an object to the queue, please make sure it implements `JsonSerializable` interface. This is how CodeIgniter [Entities](https://codeigniter.com/user_guide/models/entities.html) are handled by default.
66

7-
You may ask, why not just use `serialize` and `unserialize`? There are security reasons that keep us from doing so. These methods are not safe to use with user provided data.
7+
You may ask, why not just use `serialize` and `unserialize`? There are security reasons that keep us from doing so. These functions are not safe to use with user provided data.

0 commit comments

Comments
 (0)