-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5ed52d
commit ffc8049
Showing
2 changed files
with
50 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Net Gearman | ||
|
||
## About | ||
|
||
Net_Gearman is a package for interfacing with 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. | ||
|
||
## Installation | ||
|
||
``` | ||
$ composer require brianlmoon/net_gearman | ||
``` | ||
|
||
## Examples | ||
|
||
### Client | ||
|
||
``` | ||
$client = new Net_Gearman_Client("localhost"); | ||
$set = new Net_Gearman_Set(); | ||
$task = new Net_Gearman_Task("Reverse_String", "foobar"); | ||
$task->attachCallback( | ||
function($func, $handle, $result){ | ||
print_r($result) | ||
} | ||
); | ||
$set->addTask($task); | ||
$client->runSet($set, $timeout); | ||
``` | ||
|
||
### Job | ||
|
||
``` | ||
class Reverse_String extends Net_Gearman_Job_Common { | ||
public function run($workload) { | ||
$result = strrev($workload); | ||
return $result; | ||
} | ||
} | ||
``` | ||
|
||
### Worker | ||
|
||
For easiest use, use GearmanManager for running workers. See: https://github.com/brianlmoon/GearmanManager | ||
|
||
``` | ||
$worker = new Net_Gearman_Worker('localhost'); | ||
$worker->addAbility('Reverse_String'); | ||
$worker->beginWork(); | ||
``` |