Coder Social home page Coder Social logo

iter8-au / php-resque-ex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deancsmith/php-resque-ex

0.0 3.0 0.0 439 KB

PHP port of resque (Workers and Queueing), with phpredis support, and more logging options

License: MIT License

PHP 100.00%

php-resque-ex's Introduction

Php-Resque-ex: Resque for PHP Build Status

Resque is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later.

Background

Php-Resque-Ex is a fork of php-resque by chrisboulton. See the original README for more informations.

Additional features

This fork provides some additional features :

Support of php-redis

Autodetect and use phpredis to connect to Redis if available. Redisent is used as fallback.

Powerfull logging

Instead of piping STDOUT output to a file, you can log directly to a database, or send them elsewhere via a socket. We use Monolog to manage all the logging. See their documentation to see all the available handlers.

Log infos are augmented with more informations, and associated with a workers, a queue, and a job ID if any.

Job creation delegation

If Resque_Job_Creator class exists and is found by Resque, all jobs creation will be delegated to this class.

The best way to inject this class is to include it in you APP_INCLUDE file.

Class content is :

class Resque_Job_Creator
{
	public static function createJob($className, $args) {
		
		// $className is you job class name, the second arguments when enqueuing a job
		// $args are the arguments passed to your jobs
		
		// Instanciate your class, and return the instance
		
		return new $className();
	}
}

This is pretty useful when your autoloader can not load the class, like when classname doesn't match its filename. Some framework, like CakePHP, uses PluginName.ClassName convention for classname, and require special handling before loading.

Failed jobs logs

You can easily retrieve logs for a failed jobs in the redis database, their keys are named after their job ID. Each failed log will expire after 2 weeks to save space.

Command Line tool

Fresque is shipped by default to manage your workers. See Fresque Documentation for usage.

Installation

Clone the git repo

$ git clone git://github.com/kamisama/php-resque-ex.git

cd into the folder you just cloned

$ cd ./php-resque-ex

Download Composer

$ curl -s https://getcomposer.org/installer | php

Install dependencies

$ php composer.phar install

Usage

Use the same way as the original port, with additional ENV :

  • LOGHANDLER : Specify the handler to use for logging (File, MongoDB, Socket, etc โ€ฆ).
    See Monolog doc for all available handlers. LOGHANDLER is the name of the handler, without the "Handler" part. To use CubeHandler, just type "Cube".
  • LOGHANDLERTARGET : Information used by the handler to connect to the database.
    Depends on the type of loghandler. If it's the RotatingFileHandler, the target will be the filename. If it's CubeHandler, target will be a udp address. Refer to each Handler to see what type of argument their __construct() method requires.

If one of these two environement variable is missing, it will default to RotatingFile Handler.

  • REDIS_DATABASE : To select another redis database (default 0)
  • REDIS_NAMESPACE : To set a different namespace for the keys (default to resque)

Requirements

  • PHP 5.3+
  • Redis 2.2+

Contributors

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.