PHP Class WpGears\Gearman\Worker

Inheritance: extends WpGears\Worker
Exibir arquivo Open project: 10up/wp-gears

Public Properties

Property Type Description
$gearman_servers The list of Gearman servers.
$gearman_worker The libGearman Worker instance

Public Methods

Method Description
do_job ( array $job ) : boolean Executes a Job pulled from Gearman. On a multisite instance it switches to the target site before executing the job. And the site is restored once executing is finished.
get_async_group ( ) : string The Function Group used to split libGearman functions on a multi-network install.
get_gearman_worker ( ) : GearmanWorker | false Builds the libGearman Worker Instance if the extension is installed. Once created returns the previous instance without reinitialization.
get_servers ( ) : array The Gearman Servers to connect to as defined in wp-config.php.
register ( ) : boolean Creates a Gearman Worker and initializes the servers it should connect to. The callback that will execute a job's hook is also setup here.
work ( ) : boolean Pulls a job from the Gearman Queue and tries to execute it.

Method Details

do_job() public method

The job data contains, 1. hook - The name of the target hook to execute 2. args - Optional arguments to pass to the target hook 3. blog_id - Optional blog on a multisite to switch to, before execution Actions are fired before and after execution of the target hook. Eg:- for the action 'foo' The order of execution of actions is, 1. wp_async_task_before_job 2. wp_async_task_before_job_foo 3. foo 4. wp_async_task_after_job 5. wp_async_task_after_job_foo
public do_job ( array $job ) : boolean
$job array The job object data.
return boolean True or false based on the status of execution

get_async_group() public method

The Function Group used to split libGearman functions on a multi-network install.
public get_async_group ( ) : string
return string The prefixed group name

get_gearman_worker() public method

Builds the libGearman Worker Instance if the extension is installed. Once created returns the previous instance without reinitialization.
public get_gearman_worker ( ) : GearmanWorker | false
return GearmanWorker | false An instance of GearmanWorker

get_servers() public method

If absent the default server will be used.
public get_servers ( ) : array
return array The list of servers for this Worker.

register() public method

Creates a Gearman Worker and initializes the servers it should connect to. The callback that will execute a job's hook is also setup here.
public register ( ) : boolean
return boolean True if operation was successful else false.

work() public method

Errors are logged if the Job failed to execute.
public work ( ) : boolean
return boolean True if the job could be executed, else false

Property Details

$gearman_servers public_oe property

The list of Gearman servers.
public $gearman_servers

$gearman_worker public_oe property

The libGearman Worker instance
public $gearman_worker