Skip to content
Merged

Docs #34

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ the ``Application::bootstrap()`` function::
Configuration
=============

The following configuration should be present in your **config/app.php**::
The following configuration should be present in the config array of your **config/app.php**::

$config = [
// ...
'Queue' => [
'default' => [
// A DSN for your configured backend. default: null
Expand All @@ -53,8 +53,8 @@ The following configuration should be present in your **config/app.php**::
// The name of an event listener class to associate with the worker
'listener' => \App\Listener\WorkerListener::class,
]
]
];
],
// ...

The ``Queue`` config key can contain one or more queue configurations. Each of
these is used for interacting with a different queuing backend.
Expand All @@ -69,6 +69,8 @@ Create a Job class::

<?php
// src/Job/ExampleJob.php
declare(strict_types=1);

namespace App\Job;

use Cake\Log\LogTrait;
Expand Down Expand Up @@ -182,6 +184,8 @@ mailer class. The following example shows how to setup the trait within a mailer
class::

<?php
declare(strict_types=1);

namespace App\Mailer;

use Cake\Mailer\Mailer;
Expand All @@ -191,7 +195,7 @@ class::
{
use QueueTrait;

public function welcome($emailAddress, $username)
public function welcome(string $emailAddress, string $username): void
{
$this
->setTo($emailAddress)
Expand All @@ -218,14 +222,7 @@ a ``Processor:ACK``.
The exposed ``QueueTrait::push()`` method has a similar signature to
``Mailer::send()``, and also supports an ``$options`` array argument. The
options this array holds are the same options as those available for
``QueueManager::push()``, and additionally supports the following:

- ``emailClass``:

- default: ``Cake\Mailer\Email::class``
- description: The name of an email class to instantiate for use with the mailer
- type: string

``QueueManager::push()``.

Run the worker
==============
Expand Down
18 changes: 16 additions & 2 deletions src/QueueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,22 @@ public static function engine(string $name): SimpleClient
* to a statically callable function. When an array is used, the
* class will be constructed by Queue\Processor and have the
* named method invoked.
* @param array $args An array of data to set for the job
* @param array $options An array of options for publishing the job
* @param array $args An array of data to set for the job.
* @param array $options An array of options for publishing the job:
* - `config` - A queue config name. Defaults to 'default'.
* - `delay` - Time (in integer seconds) to delay message, after which it
* will be processed. Not all message brokers accept this. Default `null`.
* - `expires` - Time (in integer seconds) after which the message expires.
* The message will be removed from the queue if this time is exceeded
* and it has not been consumed. Default `null`.
* - `priority` - Valid values:
* - `\Enqueue\Client\MessagePriority::VERY_LOW`
* - `\Enqueue\Client\MessagePriority::LOW`
* - `\Enqueue\Client\MessagePriority::NORMAL`
* - `\Enqueue\Client\MessagePriority::HIGH`
* - `\Enqueue\Client\MessagePriority::VERY_HIGH`
* - `queue` - The name of a queue to use, from queue `config` array or
* string 'default' if empty.
* @return void
*/
public static function push($callable, array $args = [], array $options = []): void
Expand Down