A PHP library for the very promising disque distributed job queue. Features:
DateTime
Job
class, or implement your own$ composer require mariano/disque-php --no-dev
If you want to run its tests remove the --no-dev
argument.
This library provides a Queue API for easy job pushing/pulling, and direct access to all Disque commands via its Client API.
Create the client:
use Disque\Connection\Credentials;
use Disque\Client;
$nodes = [
new Credentials('127.0.0.1', 7711),
new Credentials('127.0.0.1', 7712, 'password'),
];
$disque = new Client($nodes);
Queue a job:
$job = new \Disque\Queue\Job(['name' => 'Claudia']);
$disque->queue('my_queue')->push($job);
Schedule job to be processed at a certain time:
$job = new \Disque\Queue\Job(['name' => 'Mariano']);
$disque->queue('my_queue')->schedule($job, new \DateTime('+2 hours'));
Fetch queued jobs, mark them as processed, and keep waiting on jobs:
$queue = $disque->queue('my_queue');
while ($job = $queue->pull()) {
echo "GOT JOB!";
var_dump($job->getBody());
$queue->processed($job);
}
For more information on the APIs provided, read the full documentation.
$ phpunit
Please see CONTRIBUTING for details.
If you need some help or even better want to collaborate, feel free to hit me on twitter: @mgiglesias
If you discover any security related issues, please contact @mgiglesias instead of using the issue tracker.
First and foremost, Salvatore Sanfilippo for writing what looks to be the definite solution for job queues (thanks for all the fish Gearman).
Other disque client libraries for the inspiration.
The PHP League for an awesome README.md
skeleton,
and tips about packaging PHP components.
A special acknolewdgment and appreciation for our amazing contributors!
The MIT License (MIT). Please see License File for more information.