Giter Club home page Giter Club logo

disque-php's Introduction

disque-php

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

A PHP library for the very promising disque distributed job queue. Features:

  • Support for both PHP (5.5+) and HHVM
  • No dependencies: Fast connection to Disque out-of-the-box
  • High level API to easily push jobs to a queue, and retrieve jobs from queues
  • Easily schedule jobs for execution at a certain DateTime
  • Use the built in Job class, or implement your own
  • Smart node connection support based on number of jobs produced by nodes
  • Connect to Disque with the built-in connection, or reutilize your existing Redis client (such as predis)
  • Supporting all current Disque commands, and allows you to easily implement custom commands
  • Fully unit tested

Installation

$ composer require mariano/disque-php --no-dev

If you want to run its tests remove the --no-dev argument.

Usage

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.

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Support

If you need some help or even better want to collaborate, feel free to hit me on twitter: @mgiglesias

Security

If you discover any security related issues, please contact @mgiglesias instead of using the issue tracker.

Acknowledgments

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:

  • Revisor for his incredible work on this library.

  • mvrhov for helping us support Disque RC1 node ID new format.

License

The MIT License (MIT). Please see License File for more information.

disque-php's People

Contributors

mariano avatar revisor avatar

Watchers

以原 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.