Skip to content
Open
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
13 changes: 13 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ jobs:
--health-timeout=5s
--health-retries=3

rabbitmq:
image: rabbitmq
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672
options: >-
--health-cmd="rabbitmq-diagnostics -q ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5

steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"codeigniter4/devkit": "^1.0",
"codeigniter4/framework": "^4.3",
"predis/predis": "^2.0",
"phpstan/phpstan-strict-rules": "^1.5"
"phpstan/phpstan-strict-rules": "^1.5",
"php-amqplib/php-amqplib": "^3.7"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand All @@ -38,7 +39,8 @@
},
"suggest": {
"ext-redis": "If you want to use RedisHandler",
"predis/predis": "If you want to use PredisHandler"
"predis/predis": "If you want to use PredisHandler",
"php-amqplib/php-amqplib": "If you want to use RabbitMQHandler"
},
"config": {
"allow-plugins": {
Expand Down
13 changes: 12 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Available options:
- [$database](#database)
- [$redis](#redis)
- [$predis](#predis)
- [$rabbitmq](#rabbitmq)
- [$keepDoneJobs](#keepdonejobs)
- [$keepFailedJobs](#keepfailedjobs)
- [$queueDefaultPriority](#queuedefaultpriority)
Expand All @@ -29,7 +30,7 @@ The default handler used by the library. Default value: `database`.

### $handlers

An array of available handlers. By now only `database`, `redis` and `predis` handlers are implemented.
An array of available handlers. Available handlers: `database`, `redis`, `predis`, and `rabbitmq`.

### $database

Expand Down Expand Up @@ -66,6 +67,16 @@ The configuration settings for `predis` handler. You need to have [Predis](https
* `database` - The database number. Default value: `0`.
* `prefix` - The default key prefix. Default value: `''` (not set).

### $rabbitmq

The configuration settings for `rabbitmq` handler. You need to have [php-amqplib](https://github.com/php-amqplib/php-amqplib) installed to use it.

* `host` - The RabbitMQ server host. Default value: `127.0.0.1`.
* `port` - The port number. Default value: `5672`.
* `username` - The username for authentication. Default value: `guest`.
* `password` - The password for authentication. Default value: `guest`.
* `vhost` - The virtual host to use. Default value: `/`.

### $keepDoneJobs

If the job is done, should we keep it in the table? Default value: `false`.
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ If you use `Redis` (you still need a relational database to store failed jobs):
- PHPRedis
- Predis

If you use `RabbitMQ` (you still need a relational database to store failed jobs):

- php-amqplib

### Table of Contents

* [Installation](installation.md)
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ parameters:
paths:
- src/Handlers/RedisHandler.php
- src/Handlers/PredisHandler.php
- src/Handlers/RabbitMQHandler.php
-
message: '#Call to an undefined method CodeIgniter\\Queue\\Models\\QueueJobFailedModel::affectedRows\(\).#'
paths:
Expand Down
13 changes: 13 additions & 0 deletions src/Config/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use CodeIgniter\Queue\Exceptions\QueueException;
use CodeIgniter\Queue\Handlers\DatabaseHandler;
use CodeIgniter\Queue\Handlers\PredisHandler;
use CodeIgniter\Queue\Handlers\RabbitMQHandler;
use CodeIgniter\Queue\Handlers\RedisHandler;
use CodeIgniter\Queue\Interfaces\JobInterface;
use CodeIgniter\Queue\Interfaces\QueueInterface;
Expand All @@ -37,6 +38,7 @@ class Queue extends BaseConfig
'database' => DatabaseHandler::class,
'redis' => RedisHandler::class,
'predis' => PredisHandler::class,
'rabbitmq' => RabbitMQHandler::class,
];

/**
Expand Down Expand Up @@ -75,6 +77,17 @@ class Queue extends BaseConfig
'prefix' => '',
];

/**
* RabbitMQ handler config.
*/
public array $rabbitmq = [
'host' => '127.0.0.1',
'port' => 5672,
'user' => 'guest',
'password' => 'guest',
'vhost' => '/',
];

/**
* Whether to keep the DONE jobs in the queue.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Exceptions/QueueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ public static function forIncorrectDelayValue(): static
{
return new self(lang('Queue.incorrectDelayValue'));
}

public static function forFailedJsonEncode(string $error): static
{
return new self(lang('Queue.failedToJsonEncode', [$error]));
}
}
Loading
Loading