public
Fork of lenn0x/net_gearman
Description: A PHP interface for Danga's Gearman
Homepage: http://pear.php.net/package/Net_Gearman
Clone URL: git://github.com/brianlmoon/net_gearman.git
Chris Goffinet (author)
Tue Dec 16 11:45:27 -0800 2008
commit  6e72156471311dab3a73be73615c91bb5ee6d338
tree    cd9d876d7238b7b62470850565daced39b37e4d9
parent  4705692ecfa898e96a44fccc801b1d61faef4c31
name age message
directory Net/ Loading commit data...
file README Tue Dec 16 11:45:27 -0800 2008 Checking in README from Google Code [Chris Goffinet]
directory examples/
file package.xml Sun Nov 16 13:11:42 -0800 2008 Upped package version to 0.2.0 since API has ch... [joestump]
directory tests/ Fri Apr 25 13:35:10 -0700 2008 1. Implemented most suggestions. 2. Fixed bug... [joestump]
README
Net_Gearman
About

Net_Gearman is a PEAR package for interfacing with Danga's Gearman. Gearman is a system to farm out work to other 
machines, dispatching function calls to machines that are better suited to do work, to do work in parallel, to load 
balance lots of function calls, or to call functions between languages.

Net_Gearman is currently in production at Yahoo! and Digg doing all sorts of offloaded near time processing.
Installation

   1. Install PEAR if it is not already installed on your system.
   2. Run pear install http://netgearman.googlecode.com/files/Net_Gearman-x.y.z.tgz (Replace x.y.z with the latest 
   version from the featured download to the right). 

Examples
Client

<?php

require_once 'Net/Gearman/Client.php';

$client = new Net_Gearman_Client('localhost:7003');
$client->someBackgroundJob(array(
    'userid' => 5555,
    'action' => 'new-comment'
));

?>

Job

<?php

class Net_Gearman_Job_someBackgroundJob extends Net_Gearman_Job_Common
{
    public function run($args)
    {
        if (!isset($args['userid']) || !isset($args['action'])) {
            throw new Net_Gearman_Job_Exception('Invalid/Missing arguments');
        }

        // Insert a record or something based on the $args

        return array(); // Results are returned to Gearman, except for 
                        // background jobs like this one.
    }
}

?>

Worker

<?php

require_once 'Net/Gearman/Worker.php';

$worker = new Net_Gearman_Worker('localhost:7003');
$worker->addAbility('someBackgroundJob');
$worker->beginWork();

?>