Download the PHP package silverstripe-australia/gearman without Composer
On this page you can find all versions of the php package silverstripe-australia/gearman. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download silverstripe-australia/gearman
More information about silverstripe-australia/gearman
Files in silverstripe-australia/gearman
Package gearman
Short Description A simple integration with the gearmand job processor
License BSD-3-Clause
Informations about the package gearman
SilverStripe Gearman module
Adds a basic level of support for the gearmand php job queue
Installation
- Install gearmand
-
Change its config to use a persistent queue; something like
- This uses the Net_Gearman library from publero/net_gearman for communicating with gearman; composer should manage this for you
To test the installation is correct, there's a test job you can execute
- Open two terminal windows in the SS root directory
- In the first, run php gearman/gearman_runner.php
- In the second, run php gearman/gearman_test_client.php
- You should see some information output to the first console window, indicating the job was picked up and processed as expected.
Usage
- Define a class that implements GearmanHandler
- The 'getName' method should return the name of a method on the class that will handle the processing of the job (exampleMethod)
- Start a worker by calling php gearman/gearman_runner.php
- Trigger the job by calling
$this->gearmanService->exampleMethod();
- Any params passed through to exampleMethod are passed on to the worker
- Note: This only supports 'background' jobs at the moment, so there are NO return values
Reflected worker
The 'gearman_runner' script is bound to a single instance of SilverStripe;
this means that any job spawned against the gearman server is handled and
executed by that instance of SilverStripe. In situations where you have
multiple instances of SS running, you will need to use the
reflected_runner.php
script instead of gearman_runner.php. This handler will
include the path of the SS instance that triggered the gearman job to be
executed, and will spawn a separate process to execute that gearman job within