From ffc804939123c21a492b370a46877c17656bcee9 Mon Sep 17 00:00:00 2001 From: Brian Moon Date: Fri, 3 Feb 2017 13:57:44 -0600 Subject: [PATCH] updating the README --- README | 60 ------------------------------------------------------- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 60 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 1ad28496..00000000 --- a/README +++ /dev/null @@ -1,60 +0,0 @@ -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. - -Installation - - 1. Install PEAR if it is not already installed on your system. - 2. Use git to pull this repo to your servers. Be sure where you install it is in the autoload or include path before the rest of PEAR. - -Examples -Client - -someBackgroundJob(array( - 'userid' => 5555, - 'action' => 'new-comment' -)); - -?> - -Job - - - -Worker - -For easiest use, use GearmanManager for running workers. See: https://github.com/brianlmoon/GearmanManager - -addAbility('someBackgroundJob'); -$worker->beginWork(); - -?> diff --git a/README.md b/README.md new file mode 100644 index 00000000..dbb241e5 --- /dev/null +++ b/README.md @@ -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(); +``` \ No newline at end of file