Skip to content

Commit 0afd3b2

Browse files
committed
document child process queues
fix accidental package-lock update
1 parent c0290ef commit 0afd3b2

File tree

1 file changed

+42
-4
lines changed
  • resources/views/docs/1/digging-deeper

1 file changed

+42
-4
lines changed

resources/views/docs/1/digging-deeper/queues.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,50 @@ Jobs live in the SQLite [database](/docs/digging-deeper/databases) that your app
1515
migration will have been created and migrated for you.
1616

1717
## Processing Jobs / Working the Queue
18-
When your application boots up, NativePHP starts a single queue worker, ready to process any jobs you send its way.
18+
By default, there is no configuration needed to process jobs. The `NativeServiceProvider::class` will boot up one default worker
19+
which will consume jobs from the `default` queue. If you want to run more workers or modify the configuration of any worker, you may
20+
refer to [Configuring workers](#configuring-workers).
1921

20-
There's nothing more required.
22+
### Configuring workers
23+
Once you publish the NativePHP config file using `php artisan vendor:publish`, you will find a `queue_workers` key in
24+
`config/nativephp.php`. Here are some acceptable values to get you started:
2125

22-
In the context of your user's device, it's very rare that you would need multiple queues or many workers, as your
23-
application is likely to only be used by one user at a time.
26+
```php
27+
'queue_workers' => [
28+
'one',
29+
'two',
30+
'three' => [
31+
'queues' => ['high'],
32+
'memory_limit' => 1024,
33+
'timeout' => 600,
34+
],
35+
'four' => [
36+
'queues' => ['high'],
37+
],
38+
'five' => [
39+
'memory_limit' => 1024,
40+
],
41+
],
42+
```
43+
44+
Not providing a nested array for the `memory_limit`, `queues` and `timeout` will result in default values being used.
45+
46+
### Managing workers
47+
48+
The handy `QueueWorker::up()` and `QueueWorker::down()` methods available on `Facades\QueueWorker` can be used to start
49+
and stop workers in code. This is useful for niche scenarios, but is worth mentioning nonetheless.
50+
51+
```php
52+
use Native\Laravel\Facades\QueueWorker;
53+
use Native\DTOs\QueueConfig;
54+
55+
$queueConfig = new QueueConfig(alias: 'manual', queuesToConsume: ['default'], memoryLimit: 1024, timeout: 600);
56+
57+
QueueWorker::up($queueConfig);
58+
59+
// Later...
60+
QueueWorker::down(alias: 'manual');
61+
```
2462

2563
## When to Queue
2664
Given that your database and application typically exist on the same machine (i.e. there's no network involved),

0 commit comments

Comments
 (0)