Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:mwillbanks/mwGearman

  • Loading branch information...
commit ecc93106a649a552772ff18a49f6721aca4b2003 2 parents 7136770 + d549efd
@mwillbanks authored
Showing with 61 additions and 2 deletions.
  1. +61 −2 README.md
View
63 README.md
@@ -49,9 +49,68 @@ Your composer.json should include the following.
* git submodule add [repo-url] ./vendor/mwGearman
* add 'mwGearman' to your application.config.php file
+Usage
+-----
+
+*DI Configuration for Connection Handling*
+```php
+<?php
+return array(
+ 'di' => array(
+ 'instance' => array(
+ 'mwGearman\Client\Pecl' => array(
+ 'parameters' => array(
+ 'servers' => array(
+ array('localhost'),
+ ),
+ ),
+ ),
+ 'mwGearman\Worker\Pecl' => array(
+ 'parameters' => array(
+ 'servers' => array(
+ array('localhost'),
+ ),
+ ),
+ ),
+ ),
+ ),
+);
+```
+
+*Submitting a Job to Gearman*
+```php
+<?php
+$gearman = $serviceMananger->get('mwGearman\Client\Pecl);
+$gearman->connect();
+
+$workload = 'some-string';
+
+$task = new mwGearman\Task\Task();
+$task->setBackground(true)
+ ->setFunction('myJob')
+ ->setWorkload($workload)
+ ->setUnique(crc32($workload));
+
+$handle = $gearman->doTask($task);
+```
+
+*Retrieving a Job from Gearman*
+```php
+<?php
+// this is still in progress and will likely change since jobs have not been abstracted yet
+$gearman = $serviceMananger->get('mwGearman\Worker\Pecl);
+$gearman->register('myJob', 'handleJob');
+$gearman->connect();
+while($gearman->work());
+
+function handleJob($job) {
+ $workload = $job->getWorkload();
+ echo $workload;
+}
+
+```
Roadmap
-------
-
-* Abstract connection handling
+* Abstract GearmanJob to ensure that we are properly handling jobs
* Integrate Net\_Gearman from PEAR
* Integrate Zend\Console for a BaseWorker
Please sign in to comment.
Something went wrong with that request. Please try again.