Gearman

目录

简介

Represents a class for connecting to a Gearman job server and making requests to perform some function on provided data. The function performed must be one registered by a Gearman worker and the data passed is opaque to the job server.

类摘要

GearmanClient

class GearmanClient {

/* 方法 */

public bool addOptions ( int $options )

public bool addServer ([ string $host = 127.0.0.1 [, int $port = 4730 ]] )

public bool addServers ([ string $servers = 127.0.0.1:4730 ] )

public GearmanTask addTask ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

public GearmanTask addTaskBackground ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

public GearmanTask addTaskHigh ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

public GearmanTask addTaskHighBackground ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

public GearmanTask addTaskLow ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

public GearmanTask addTaskLowBackground ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

public GearmanTask addTaskStatus ( string $job_handle [, string &$context ] )

public bool clearCallbacks ( void )

public GearmanClient clone ( void )

public __construct ( void )

public string context ( void )

public string data ( void )

public string do ( string $function_name , string $workload [, string $unique ] )

public string doBackground ( string $function_name , string $workload [, string $unique ] )

public string doHigh ( string $function_name , string $workload [, string $unique ] )

public string doHighBackground ( string $function_name , string $workload [, string $unique ] )

public string doJobHandle ( void )

public string doLow ( string $function_name , string $workload [, string $unique ] )

public string doLowBackground ( string $function_name , string $workload [, string $unique ] )

public string doNormal ( string $function_name , string $workload [, string $unique ] )

public array doStatus ( void )

public bool echo ( string $workload )

public string error ( void )

public int getErrno ( void )

public array jobStatus ( string $job_handle )

public bool ping ( string $workload )

public bool removeOptions ( int $options )

public int returnCode ( void )

public bool runTasks ( void )

public void setClientCallback ( callable $callback )

public bool setCompleteCallback ( callable $callback )

public bool setContext ( string $context )

public bool setCreatedCallback ( string $callback )

public bool setData ( string $data )

public bool setDataCallback ( callable $callback )

public bool setExceptionCallback ( callable $callback )

public bool setFailCallback ( callable $callback )

public bool setOptions ( int $options )

public bool setStatusCallback ( callable $callback )

public bool setTimeout ( int $timeout )

public bool setWarningCallback ( callable $callback )

public bool setWorkloadCallback ( callable $callback )

public int timeout ( void )

}

GearmanClient::addOptions

Add client options

说明

public bool GearmanClient::addOptions ( int $options )

Adds one or more options to those already set.

参数

options
The options to add. One of the following constants, or a combination of them using the bitwise OR operator (“|”): GEARMAN_CLIENT_GENERATE_UNIQUE, GEARMAN_CLIENT_NON_BLOCKING, GEARMAN_CLIENT_UNBUFFERED_RESULT or GEARMAN_CLIENT_FREE_TASKS.

返回值

Always returns TRUE.

GearmanClient::addServer

Add a job server to the client

说明

public bool GearmanClient::addServer ([ string $host = 127.0.0.1 [, int $port = 4730 ]] )

Adds a job server to a list of servers that can be used to run a task. No socket I/O happens here; the server is simply added to the list.

参数

host
任务服务器主机名。

port
任务服务器端口号。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 Adding two job servers

<?php

# Create our client object.
$gmclient= new GearmanClient();

# Add two job servers, the first on the default 4730 port
$gmclient->addServer("10.0.0.1"); 
$gmclient->addServer("10.0.0.2", 7003);

?>

参见

  • GearmanClient::addServers

GearmanClient::addServers

Add a list of job servers to the client

说明

public bool GearmanClient::addServers ([ string $servers = 127.0.0.1:4730 ] )

Adds a list of job servers that can be used to run a task. No socket I/O happens here; the servers are simply added to the full list of servers.

参数

servers
A comma-separated list of servers, each server specified in the format 'host:port'.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 Add two job servers

<?php

# Create our client object.
$gmclient= new GearmanClient();

# Add multiple job servers, the first on the default 4730 port
$gmclient->addServers("10.0.0.1,10.0.0.2:7003");

?>

参见

  • GearmanClient::addServer

GearmanClient::addTask

Add a task to be run in parallel

说明

public GearmanTask GearmanClient::addTask ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

Adds a task to be run in parallel with other tasks. Call this method for all the tasks to be run in parallel, then call GearmanClient::runTasks to perform the work. Note that enough workers need to be available for the tasks to all run in parallel.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

context
与任务关联的应用程序上下文。

unique
用于标识特定任务的唯一性 ID。

返回值

A GearmanTask object or FALSE if the task could not be added.

范例

示例 #1 Basic submission of two tasks

<?php

# Create our gearman client
$gmclient= new GearmanClient(); 

# add the default job server
$gmclient->addServer(); 

# set a function to be called when the work is complete
$gmclient->setCompleteCallback("complete"); 

# add a task to perform the "reverse" function on the string "Hello World!"
$gmclient->addTask("reverse", "Hello World!", null, "1"); 

# add another task to perform the "reverse" function on the string "!dlroW olleH"
$gmclient->addTask("reverse", "!dlroW olleH", null, "2"); 

# run the tasks
$gmclient->runTasks(); 

function complete($task) 
{ 
  print "COMPLETE: " . $task->unique() . ", " . $task->data() . "\n"; 
}

?>

以上例程的输出类似于:

COMPLETE: 2, Hello World!
COMPLETE: 1, !dlroW olleH

示例 #2 Basic submission of two tasks with passing application context

<?php

$client = new GearmanClient();
$client->addServer();

# set a function to be called when the work is complete
$client->setCompleteCallback("reverse_complete");

# Add some tasks for a placeholder of where to put the results
$results = array();
$client->addTask("reverse", "Hello World!", &$results, "t1");
$client->addTask("reverse", "!dlroW olleH", &$results, "t2");

$client->runTasks();

# The results should now be filled in from the callbacks
foreach ($results as $id => $result)
   echo $id . ": " . $result['handle'] . ", " . $result['data'] . "\n";


function reverse_complete($task, $results)
{
   $results[$task->unique()] = array("handle"=>$task->jobHandle(), "data"=>$task->data());
}

?>

以上例程的输出类似于:

t2: H.foo:21, Hello World!
t1: H:foo:22, !dlroW olleH

参见

  • GearmanClient::addTaskHigh
  • GearmanClient::addTaskLow
  • GearmanClient::addTaskBackground
  • GearmanClient::addTaskHighBackground
  • GearmanClient::addTaskLowBackground
  • GearmanClient::runTasks

GearmanClient::addTaskBackground

Add a background task to be run in parallel

说明

public GearmanTask GearmanClient::addTaskBackground ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

Adds a background task to be run in parallel with other tasks. Call this method for all the tasks to be run in parallel, then call GearmanClient::runTasks to perform the work.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

context
与任务关联的应用程序上下文。

unique
用于标识特定任务的唯一性 ID。

返回值

A GearmanTask object or FALSE if the task could not be added.

范例

示例 #1 Two tasks, one background and one not

This example illustrates the difference between running a background task and a normal task. The client adds two tasks to execute the same function, but one is added with addTaskBackground. A callback is set so that progress of the job can be tracked. A simple worker with an artificial delay reports on the job progress and the client picks this up through the callback. Two workers are run for this example. Note that the background task does not show in the client output.

<?php

# The client script

# create our gearman client
$gmc= new GearmanClient();

# add the default job server
$gmc->addServer();

# set a couple of callbacks so we can track progress
$gmc->setCompleteCallback("reverse_complete");
$gmc->setStatusCallback("reverse_status");

# add a task for the "reverse" function
$task= $gmc->addTask("reverse", "Hello World!", null, "1");

# add another task, but this one to run in the background
$task= $gmc->addTaskBackground("reverse", "!dlroW olleH", null, "2");

if (! $gmc->runTasks())
{
    echo "ERROR " . $gmc->error() . "\n";
    exit;
}

echo "DONE\n";

function reverse_status($task)
{
    echo "STATUS: " . $task->unique() . ", " . $task->jobHandle() . " - " . $task->taskNumerator() . 
         "/" . $task->taskDenominator() . "\n";
}

function reverse_complete($task)
{
    echo "COMPLETE: " . $task->unique() . ", " . $task->data() . "\n";
}

?>
<?php

# The worker script

echo "Starting\n";

# Create our worker object.
$gmworker= new GearmanWorker();

# Add default server (localhost).
$gmworker->addServer();

# Register function "reverse" with the server.
$gmworker->addFunction("reverse", "reverse_fn");

print "Waiting for job...\n";
while($gmworker->work())
{
  if ($gmworker->returnCode() != GEARMAN_SUCCESS)
  {
    echo "return_code: " . $gmworker->returnCode() . "\n";
    break;
  }
}

function reverse_fn($job)
{
  echo "Received job: " . $job->handle() . "\n";

  $workload = $job->workload();
  $workload_size = $job->workloadSize();

  echo "Workload: $workload ($workload_size)\n";

  # This status loop is not needed, just showing how it works
  for ($x= 0; $x < $workload_size; $x++)
  {
    echo "Sending status: " . ($x + 1) . "/$workload_size complete\n";
    $job->sendStatus($x+1, $workload_size);
    $job->sendData(substr($workload, $x, 1));
    sleep(1);
  }

  $result= strrev($workload);
  echo "Result: $result\n";

  # Return what we want to send back to the client.
  return $result;
}

?>

Worker output for two workers running:

Received job: H:foo.local:65
Workload: !dlroW olleH (12)
1/12 complete
Received job: H:foo.local:66
Workload: Hello World! (12)
Sending status: 1/12 complete
Sending status: 2/12 complete
Sending status: 2/12 complete
Sending status: 3/12 complete
Sending status: 3/12 complete
Sending status: 4/12 complete
Sending status: 4/12 complete
Sending status: 5/12 complete
Sending status: 5/12 complete
Sending status: 6/12 complete
Sending status: 6/12 complete
Sending status: 7/12 complete
Sending status: 7/12 complete
Sending status: 8/12 complete
Sending status: 8/12 complete
Sending status: 9/12 complete
Sending status: 9/12 complete
Sending status: 10/12 complete
Sending status: 10/12 complete
Sending status: 11/12 complete
Sending status: 11/12 complete
Sending status: 12/12 complete
Sending status: 12/12 complete
Result: !dlroW olleH
Result: Hello World!

Client output:

STATUS: 1, H:foo.local:66 - 1/12
STATUS: 1, H:foo.local:66 - 2/12
STATUS: 1, H:foo.local:66 - 3/12
STATUS: 1, H:foo.local:66 - 4/12
STATUS: 1, H:foo.local:66 - 5/12
STATUS: 1, H:foo.local:66 - 6/12
STATUS: 1, H:foo.local:66 - 7/12
STATUS: 1, H:foo.local:66 - 8/12
STATUS: 1, H:foo.local:66 - 9/12
STATUS: 1, H:foo.local:66 - 10/12
STATUS: 1, H:foo.local:66 - 11/12
STATUS: 1, H:foo.local:66 - 12/12
COMPLETE: 1, !dlroW olleH
DONE

参见

  • GearmanClient::addTask
  • GearmanClient::addTaskHigh
  • GearmanClient::addTaskLow
  • GearmanClient::addTaskHighBackground
  • GearmanClient::addTaskLowBackground
  • GearmanClient::runTasks

GearmanClient::addTaskHigh

Add a high priority task to run in parallel

说明

public GearmanTask GearmanClient::addTaskHigh ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

Adds a high priority task to be run in parallel with other tasks. Call this method for all the high priority tasks to be run in parallel, then call GearmanClient::runTasks to perform the work. Tasks with a high priority will be selected from the queue before those of normal or low priority.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

context
与任务关联的应用程序上下文。

unique
用于标识特定任务的唯一性 ID。

返回值

A GearmanTask object or FALSE if the task could not be added.

范例

示例 #1 A high priority task along with two normal tasks

A high priority task is included among two other tasks. A single worker is available, so that tasks are run one at a time, with the high priority task run first.

<?php

# create the gearman client
$gmc= new GearmanClient();

# add the default job server
$gmc->addServer();

# set the callback for when the job is complete
$gmc->setCompleteCallback("reverse_complete");

# add tasks, one of which is high priority
$task= $gmc->addTask("reverse", "Hello World!", null, "1");
$task= $gmc->addTaskHigh("reverse", "!dlroW olleH", null, "2");
$task= $gmc->addTask("reverse", "Hello World!", null, "3");

if (! $gmc->runTasks())
{
    echo "ERROR " . $gmc->error() . "\n";
    exit;
}
echo "DONE\n";

function reverse_complete($task)
{
    echo "COMPLETE: " . $task->unique() . ", " . $task->data() . "\n";
}

?>

以上例程的输出类似于:

COMPLETE: 2, Hello World!
COMPLETE: 3, !dlroW olleH
COMPLETE: 1, !dlroW olleH
DONE

参见

  • GearmanClient::addTask
  • GearmanClient::addTaskLow
  • GearmanClient::addTaskBackground
  • GearmanClient::addTaskHighBackground
  • GearmanClient::addTaskLowBackground
  • GearmanClient::runTasks

GearmanClient::addTaskHighBackground

Add a high priority background task to be run in parallel

说明

public GearmanTask GearmanClient::addTaskHighBackground ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

Adds a high priority background task to be run in parallel with other tasks. Call this method for all the tasks to be run in parallel, then call GearmanClient::runTasks to perform the work. Tasks with a high priority will be selected from the queue before those of normal or low priority.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

context
与任务关联的应用程序上下文。

unique
用于标识特定任务的唯一性 ID。

返回值

A GearmanTask object or FALSE if the task could not be added.

参见

  • GearmanClient::addTask
  • GearmanClient::addTaskHigh
  • GearmanClient::addTaskLow
  • GearmanClient::addTaskBackground
  • GearmanClient::addTaskLowBackground
  • GearmanClient::runTasks

GearmanClient::addTaskLow

Add a low priority task to run in parallel

说明

public GearmanTask GearmanClient::addTaskLow ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

Adds a low priority background task to be run in parallel with other tasks. Call this method for all the tasks to be run in parallel, then call GearmanClient::runTasks to perform the work. Tasks with a low priority will be selected from the queue after those of normal or low priority.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

context
与任务关联的应用程序上下文。

unique
用于标识特定任务的唯一性 ID。

返回值

A GearmanTask object or FALSE if the task could not be added.

范例

示例 #1 A low priority task along with two normal tasks

A low priority task is included among two other tasks. A single worker is available, so that tasks are run one at a time, with the low priority task run last.

<?php

# create the gearman client
$gmc= new GearmanClient();

# add the default job server
$gmc->addServer();

# set the callback for when the job is complete
$gmc->setCompleteCallback("reverse_complete");

# add tasks, one of which is low priority
$task= $gmc->addTask("reverse", "Hello World!", null, "1");
$task= $gmc->addTaskLow("reverse", "!dlroW olleH", null, "2");
$task= $gmc->addTask("reverse", "Hello World!", null, "3");

if (! $gmc->runTasks())
{
    echo "ERROR " . $gmc->error() . "\n";
    exit;
}
echo "DONE\n";

function reverse_complete($task)
{
    echo "COMPLETE: " . $task->unique() . ", " . $task->data() . "\n";
}

?>

以上例程的输出类似于:

COMPLETE: 3, !dlroW olleH
COMPLETE: 1, !dlroW olleH
COMPLETE: 2, Hello World!
DONE

参见

  • GearmanClient::addTask
  • GearmanClient::addTaskHigh
  • GearmanClient::addTaskBackground
  • GearmanClient::addTaskHighBackground
  • GearmanClient::addTaskLowBackground
  • GearmanClient::runTasks

GearmanClient::addTaskLowBackground

Add a low priority background task to be run in parallel

说明

public GearmanTask GearmanClient::addTaskLowBackground ( string $function_name , string $workload [, mixed &$context [, string $unique ]] )

Adds a low priority background task to be run in parallel with other tasks. Call this method for all the tasks to be run in parallel, then call GearmanClient::runTasks to perform the work. Tasks with a low priority will be selected from the queue after those of normal or high priority.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

context
与任务关联的应用程序上下文。

unique
用于标识特定任务的唯一性 ID。

返回值

A GearmanTask object or FALSE if the task could not be added.

参见

  • GearmanClient::addTask
  • GearmanClient::addTaskHigh
  • GearmanClient::addTaskLow
  • GearmanClient::addTaskBackground
  • GearmanClient::addTaskHighBackground
  • GearmanClient::runTasks

GearmanClient::addTaskStatus

Add a task to get status

说明

public GearmanTask GearmanClient::addTaskStatus ( string $job_handle [, string &$context ] )

Used to request status information from the Gearman server, which will call the specified status callback (set using GearmanClient::setStatusCallback).

参数

job_handle
The job handle for the task to get status for

context
Data to be passed to the status callback, generally a reference to an array or object

返回值

A GearmanTask object.

范例

示例 #1 Monitor completion of multiple background tasks

An artificial delay is introduced in the worker in this example to simulate a long running process. There is only one worker running for this example.

<?php

/* create our object */
$gmclient= new GearmanClient();

/* add the default server */
$gmclient->addServer();

/* start some background jobs and save the handles */
$handles = array();
$handles[0] = $gmclient->doBackground("reverse", "Hello World!");
$handles[1] = $gmclient->doBackground("reverse", "!dlroW olleH");

$gmclient->setStatusCallback("reverse_status");

/* Poll the server to see when those background jobs finish; */
/* a better method would be to use event callbacks */
do
{
   /* Use the context variable to track how many tasks have completed */
   $done = 0;
   $gmclient->addTaskStatus($handles[0], &$done);
   $gmclient->addTaskStatus($handles[1], &$done);
   $gmclient->runTasks();
   echo "Done: $done\n";
   sleep(1);
}
while ($done != 2);

function reverse_status($task, $done)
{
   if (!$task->isKnown())
      $done++;
}

?>

以上例程的输出类似于:

Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 0
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 1
Done: 2

参见

  • GearmanClient::setStatusCallback

GearmanClient::clearCallbacks

Clear all task callback functions

说明

public bool GearmanClient::clearCallbacks ( void )

Clears all the task callback functions that have previously been set.

参数

此函数没有参数。

返回值

Always returns TRUE.

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::clone

Create a copy of a GearmanClient object

说明

public GearmanClient GearmanClient::clone ( void )

Creates a copy of a GearmanClient object.

参数

此函数没有参数。

返回值

A GearmanClient on success, FALSE on failure.

GearmanClient::__construct

Create a GearmanClient instance

说明

public GearmanClient::__construct ( void )

Creates a GearmanClient instance representing a client that connects to the job server and submits tasks to complete.

参数

此函数没有参数。

返回值

A GearmanClient object.

参见

  • GearmanClient::clone

GearmanClient::context

Get the application context

说明

public string GearmanClient::context ( void )

Get the application context previously set with GearmanClient::setContext.

参数

此函数没有参数。

返回值

The same context data structure set with GearmanClient::setContext

参见

  • GearmanClient::setContext

GearmanClient::data

Get the application data (deprecated)

说明

public string GearmanClient::data ( void )

Get the application data previously set with GearmanClient::setData.

Note:

This method was replaced by class="methodname">GearmanClient::setContext in the 0.6.0 release of the Gearman extension.

参数

此函数没有参数。

返回值

The same string data set with GearmanClient::setData

参见

  • GearmanClient::setData

GearmanClient::do

Run a single task and return a result [deprecated]

说明

public string GearmanClient::do ( string $function_name , string $workload [, string $unique ] )

The GearmanClient::do method is deprecated as of pecl/gearman 1.0.0. Use GearmanClient::doNormal.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

unique
用于标识特定任务的唯一性 ID。

返回值

A string representing the results of running a task.

范例

示例 #1 Simple job submission with immediate return

<?php

# Client code

echo "Starting\n";

# Create our client object.
$gmclient= new GearmanClient();

# Add default server (localhost).
$gmclient->addServer();

echo "Sending job\n";

$result = $gmclient->doNormal("reverse", "Hello!");

echo "Success: $result\n";

?>
<?php

echo "Starting\n";

# Create our worker object.
$gmworker= new GearmanWorker();

# Add default server (localhost).
$gmworker->addServer();

# Register function "reverse" with the server. Change the worker function to
# "reverse_fn_fast" for a faster worker with no output.
$gmworker->addFunction("reverse", "reverse_fn");

print "Waiting for job...\n";
while($gmworker->work())
{
  if ($gmworker->returnCode() != GEARMAN_SUCCESS)
  {
    echo "return_code: " . $gmworker->returnCode() . "\n";
    break;
  }
}

function reverse_fn($job)
{
  return strrev($job->workload());
}

?>

以上例程的输出类似于:

Starting
Sending job
Success: !olleH

示例 #2 Submitting a job and retrieving incremental status

A job is submitted and the script loops to retrieve status information. The worker has an artificial delay which results in a long running job and sends status and data as processing occurs. Each subsequent call to GearmanClient::do produces status information on the running job.

<?php

# Client code

# Create our client object.
$gmclient= new GearmanClient();

# Add default server (localhost).
$gmclient->addServer();

echo "Sending job\n";

# Send reverse job
do
{
  $result = $gmclient->doNormal("reverse", "Hello!");
  # Check for various return packets and errors.

  switch($gmclient->returnCode())
  {
    case GEARMAN_WORK_DATA:
      echo "Data: $result\n";
      break;
    case GEARMAN_WORK_STATUS:
      list($numerator, $denominator)= $gmclient->doStatus();
      echo "Status: $numerator/$denominator complete\n";
      break;
    case GEARMAN_WORK_FAIL:
      echo "Failed\n";
      exit;
    case GEARMAN_SUCCESS:
      break;
    default:
      echo "RET: " . $gmclient->returnCode() . "\n";
      echo "Error: " . $gmclient->error() . "\n";
      echo "Errno: " . $gmclient->getErrno() . "\n";
      exit;
  }
}
while($gmclient->returnCode() != GEARMAN_SUCCESS);

echo "Success: $result\n";

?>
<?php

# Worker code

echo "Starting\n";

# Create our worker object.
$gmworker= new GearmanWorker();

# Add default server (localhost).
$gmworker->addServer();

# Register function "reverse" with the server.
$gmworker->addFunction("reverse", "reverse_fn");

print "Waiting for job...\n";
while($gmworker->work())
{
  if ($gmworker->returnCode() != GEARMAN_SUCCESS)
  {
    echo "return_code: " . $gmworker->returnCode() . "\n";
    break;
  }
}

function reverse_fn($job)
{
  echo "Received job: " . $job->handle() . "\n";

  $workload = $job->workload();
  $workload_size = $job->workloadSize();

  echo "Workload: $workload ($workload_size)\n";

  # This status loop is not needed, just showing how it works
  for ($x= 0; $x < $workload_size; $x++)
  {
    echo "Sending status: " + $x + 1 . "/$workload_size complete\n";
    $job->sendStatus($x+1, $workload_size);
    $job->sendData(substr($workload, $x, 1));
    sleep(1);
  }

  $result= strrev($workload);
  echo "Result: $result\n";

  # Return what we want to send back to the client.
  return $result;
}

?>

以上例程的输出类似于:

Worker output:

Starting
Waiting for job...
Received job: H:foo.local:106
Workload: Hello! (6)
1/6 complete
2/6 complete
3/6 complete
4/6 complete
5/6 complete
6/6 complete
Result: !olleH

Client output:

Starting
Sending job
Status: 1/6 complete
Data: H
Status: 2/6 complete
Data: e
Status: 3/6 complete
Data: l
Status: 4/6 complete
Data: l
Status: 5/6 complete
Data: o
Status: 6/6 complete
Data: !
Success: !olleH

参见

  • GearmanClient::doHigh
  • GearmanClient::doLow
  • GearmanClient::doBackground
  • GearmanClient::doHighBackground
  • GearmanClient::doLowBackground

GearmanClient::doBackground

Run a task in the background

说明

public string GearmanClient::doBackground ( string $function_name , string $workload [, string $unique ] )

Runs a task in the background, returning a job handle which can be used to get the status of the running task.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

unique
用于标识特定任务的唯一性 ID。

返回值

The job handle for the submitted task.

范例

示例 #1 Submit and monitor a background job

The worker in this example has an artificial delay introduced to mimic a long running job. The client script periodically checks the status of the running job.

<?php

/* create our object */
$gmclient= new GearmanClient();

/* add the default server */
$gmclient->addServer();

/* run reverse client */
$job_handle = $gmclient->doBackground("reverse", "this is a test");

if ($gmclient->returnCode() != GEARMAN_SUCCESS)
{
  echo "bad return code\n";
  exit;
}

$done = false;
do
{
   sleep(3);
   $stat = $gmclient->jobStatus($job_handle);
   if (!$stat[0]) // the job is known so it is not done
      $done = true;
   echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denominator: " . $stat[3] . "\n";
}
while(!$done);

echo "done!\n";

?>

以上例程的输出类似于:

Running: true, numerator: 3, denominator: 14
Running: true, numerator: 6, denominator: 14
Running: true, numerator: 9, denominator: 14
Running: true, numerator: 12, denominator: 14
Running: false, numerator: 0, denominator: 0
done!

参见

  • GearmanClient::doNormal
  • GearmanClient::doHigh
  • GearmanClient::doLow
  • GearmanClient::doHighBackground
  • GearmanClient::doLowBackground

GearmanClient::doHigh

Run a single high priority task

说明

public string GearmanClient::doHigh ( string $function_name , string $workload [, string $unique ] )

Runs a single high priority task and returns a string representation of the result. It is up to the GearmanClient and GearmanWorker to agree on the format of the result. High priority tasks will get precedence over normal and low priority tasks in the job queue.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

unique
用于标识特定任务的唯一性 ID。

返回值

A string representing the results of running a task.

参见

  • GearmanClient::doNormal
  • GearmanClient::doLow
  • GearmanClient::doBackground
  • GearmanClient::doHighBackground
  • GearmanClient::doLowBackground

GearmanClient::doHighBackground

Run a high priority task in the background

说明

public string GearmanClient::doHighBackground ( string $function_name , string $workload [, string $unique ] )

Runs a high priority task in the background, returning a job handle which can be used to get the status of the running task. High priority tasks take precedence over normal and low priority tasks in the job queue.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

unique
用于标识特定任务的唯一性 ID。

返回值

The job handle for the submitted task.

参见

  • GearmanClient::doNormal
  • GearmanClient::doHigh
  • GearmanClient::doLow
  • GearmanClient::doBackground
  • GearmanClient::doLowBackground

GearmanClient::doJobHandle

Get the job handle for the running task

说明

public string GearmanClient::doJobHandle ( void )

Gets that job handle for a running task. This should be used between repeated GearmanClient::doNormal calls. The job handle can then be used to get information on the task.

参数

此函数没有参数。

返回值

The job handle for the running task.

参见

  • GearmanClient::jobStatus

GearmanClient::doLow

Run a single low priority task

说明

public string GearmanClient::doLow ( string $function_name , string $workload [, string $unique ] )

Runs a single low priority task and returns a string representation of the result. It is up to the GearmanClient and GearmanWorker to agree on the format of the result. Normal and high priority tasks will get precedence over low priority tasks in the job queue.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

unique
用于标识特定任务的唯一性 ID。

返回值

A string representing the results of running a task.

参见

  • GearmanClient::doNormal
  • GearmanClient::doHigh
  • GearmanClient::doBackground
  • GearmanClient::doHighBackground
  • GearmanClient::doLowBackground

GearmanClient::doLowBackground

Run a low priority task in the background

说明

public string GearmanClient::doLowBackground ( string $function_name , string $workload [, string $unique ] )

Runs a low priority task in the background, returning a job handle which can be used to get the status of the running task. Normal and high priority tasks take precedence over low priority tasks in the job queue.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

unique
用于标识特定任务的唯一性 ID。

返回值

The job handle for the submitted task.

参见

  • GearmanClient::doNormal
  • GearmanClient::doHigh
  • GearmanClient::doLow
  • GearmanClient::doBackground
  • GearmanClient::doHighBackground

GearmanClient::doNormal

Run a single task and return a result

说明

public string GearmanClient::doNormal ( string $function_name , string $workload [, string $unique ] )

Runs a single task and returns a string representation of the result. It is up to the GearmanClient and GearmanWorker to agree on the format of the result.

参数

function_name
由程序自动执行的已注册函数。

workload
被处理的序列化数据。

unique
用于标识特定任务的唯一性 ID。

返回值

A string representing the results of running a task.

范例

示例 #1 Simple job submission with immediate return

<?php

?>
<?php

# Client code

echo "Starting\n";

# Create our client object.
$gmclient= new GearmanClient();

# Add default server (localhost).
$gmclient->addServer();

echo "Sending job\n";

$result = $gmclient->doNormal("reverse", "Hello!");

echo "Success: $result\n";

?>
<?php

echo "Starting\n";

# Create our worker object.
$gmworker= new GearmanWorker();

# Add default server (localhost).
$gmworker->addServer();

# Register function "reverse" with the server. Change the worker function to
# "reverse_fn_fast" for a faster worker with no output.
$gmworker->addFunction("reverse", "reverse_fn");

print "Waiting for job...\n";
while($gmworker->work())
{
  if ($gmworker->returnCode() != GEARMAN_SUCCESS)
  {
    echo "return_code: " . $gmworker->returnCode() . "\n";
    break;
  }
}

function reverse_fn($job)
{
  return strrev($job->workload());
}

?>

以上例程的输出类似于:

Starting
Sending job
Success: !olleH

示例 #2 Submitting a job and retrieving incremental status

A job is submitted and the script loops to retrieve status information. The worker has an artificial delay which results in a long running job and sends status and data as processing occurs. Each subsequent call to GearmanClient::doNormal produces status information on the running job.

<?php

# Client code

# Create our client object.
$gmclient= new GearmanClient();

# Add default server (localhost).
$gmclient->addServer();

echo "Sending job\n";

# Send reverse job
do
{
  $result = $gmclient->doNormal("reverse", "Hello!");
  # Check for various return packets and errors.

  switch($gmclient->returnCode())
  {
    case GEARMAN_WORK_DATA:
      echo "Data: $result\n";
      break;
    case GEARMAN_WORK_STATUS:
      list($numerator, $denominator)= $gmclient->doStatus();
      echo "Status: $numerator/$denominator complete\n";
      break;
    case GEARMAN_WORK_FAIL:
      echo "Failed\n";
      exit;
    case GEARMAN_SUCCESS:
      break;
    default:
      echo "RET: " . $gmclient->returnCode() . "\n";
      echo "Error: " . $gmclient->error() . "\n";
      echo "Errno: " . $gmclient->getErrno() . "\n";
      exit;
  }
}
while($gmclient->returnCode() != GEARMAN_SUCCESS);

echo "Success: $result\n";

?>
<?php

# Worker code

echo "Starting\n";

# Create our worker object.
$gmworker= new GearmanWorker();

# Add default server (localhost).
$gmworker->addServer();

# Register function "reverse" with the server.
$gmworker->addFunction("reverse", "reverse_fn");

print "Waiting for job...\n";
while($gmworker->work())
{
  if ($gmworker->returnCode() != GEARMAN_SUCCESS)
  {
    echo "return_code: " . $gmworker->returnCode() . "\n";
    break;
  }
}

function reverse_fn($job)
{
  echo "Received job: " . $job->handle() . "\n";

  $workload = $job->workload();
  $workload_size = $job->workloadSize();

  echo "Workload: $workload ($workload_size)\n";

  # This status loop is not needed, just showing how it works
  for ($x= 0; $x < $workload_size; $x++)
  {
    echo "Sending status: " + $x + 1 . "/$workload_size complete\n";
    $job->sendStatus($x+1, $workload_size);
    $job->sendData(substr($workload, $x, 1));
    sleep(1);
  }

  $result= strrev($workload);
  echo "Result: $result\n";

  # Return what we want to send back to the client.
  return $result;
}

?>

以上例程的输出类似于:

Worker output:

Starting
Waiting for job...
Received job: H:foo.local:106
Workload: Hello! (6)
1/6 complete
2/6 complete
3/6 complete
4/6 complete
5/6 complete
6/6 complete
Result: !olleH

Client output:

Starting
Sending job
Status: 1/6 complete
Data: H
Status: 2/6 complete
Data: e
Status: 3/6 complete
Data: l
Status: 4/6 complete
Data: l
Status: 5/6 complete
Data: o
Status: 6/6 complete
Data: !
Success: !olleH

参见

  • GearmanClient::doHigh
  • GearmanClient::doLow
  • GearmanClient::doBackground
  • GearmanClient::doHighBackground
  • GearmanClient::doLowBackground

GearmanClient::doStatus

Get the status for the running task

说明

public array GearmanClient::doStatus ( void )

Returns the status for the running task. This should be used between repeated GearmanClient::doNormal calls.

参数

此函数没有参数。

返回值

An array representing the percentage completion given as a fraction, with the first element the numerator and the second element the denomintor.

范例

示例 #1 Get the status of a long running job

The worker in this example has an artificial delay added during processing of the string to be reversed. After each delay it calls GearmanJob::status which the client then picks up.

<?php

echo "Starting\n";

# Create our client object.
$gmclient= new GearmanClient();

# Add default server (localhost).
$gmclient->addServer();

echo "Sending job\n";

# Send reverse job
do
{
  $result = $gmclient->doNormal("reverse", "Hello!");

  # Check for various return packets and errors.
  switch($gmclient->returnCode())
  {
    case GEARMAN_WORK_DATA:
      break;
    case GEARMAN_WORK_STATUS:
      # get the current job status
      list($numerator, $denominator)= $gmclient->doStatus();
      echo "Status: $numerator/$denominator complete\n";
      break;
    case GEARMAN_WORK_FAIL:
      echo "Failed\n";
      exit;
    case GEARMAN_SUCCESS:
      break;
    default:
      echo "RET: " . $gmclient->returnCode() . "\n";
      exit;
  }
}
while($gmclient->returnCode() != GEARMAN_SUCCESS);

echo "Success: $result\n";

?>

以上例程的输出类似于:

Starting
Sending job
Status: 1/6 complete
Status: 2/6 complete
Status: 3/6 complete
Status: 4/6 complete
Status: 5/6 complete
Status: 6/6 complete
Success: !olleH

参见

  • GearmanClient::doNormal
  • GearmanJob::status

GearmanClient::echo

Send data to all job servers to see if they echo it back [deprecated]

说明

public bool GearmanClient::echo ( string $workload )

The GearmanClient::echo method is deprecated as of pecl/gearman 1.0.0. Use GearmanClient::ping.

参数

workload
Some arbitrary serialized data to be echo back

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

GearmanClient::error

Returns an error string for the last error encountered

说明

public string GearmanClient::error ( void )

Returns an error string for the last error encountered.

参数

此函数没有参数。

返回值

A human readable error string.

参见

  • GearmanClient::getErrno

GearmanClient::getErrno

Get an errno value

说明

public int GearmanClient::getErrno ( void )

Value of errno in the case of a GEARMAN_ERRNO return value.

参数

此函数没有参数。

返回值

A valid Gearman errno.

参见

  • GearmanClient::error

GearmanClient::jobStatus

gearman_job_status

Get the status of a background job

说明

面向对象风格 (method):

public array GearmanClient::jobStatus ( string $job_handle )

Gets the status for a background job given a job handle. The status information will specify whether the job is known, whether the job is currently running, and the percentage completion.

参数

job_handle
由 Gearman 服务器指派的工作句柄。

返回值

An array containing status information for the job corresponding to the supplied job handle. The first array element is a boolean indicating whether the job is even known, the second is a boolean indicating whether the job is still running, and the third and fourth elements correspond to the numerator and denominator of the fractional completion percentage, respectively.

范例

示例 #1 Monitor the status of a long running background job

<?php

/* create our object */
$gmclient= new GearmanClient();

/* add the default server */
$gmclient->addServer();

/* run reverse client */
$job_handle = $gmclient->doBackground("reverse", "this is a test");

if ($gmclient->returnCode() != GEARMAN_SUCCESS)
{
  echo "bad return code\n";
  exit;
}

$done = false;
do
{
   sleep(3);
   $stat = $gmclient->jobStatus($job_handle);
   if (!$stat[0]) // the job is known so it is not done
      $done = true;
   echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . "\n";
}
while(!$done);

echo "done!\n";

?>

以上例程的输出类似于:

Running: true, numerator: 3, denomintor: 14
Running: true, numerator: 6, denomintor: 14
Running: true, numerator: 9, denomintor: 14
Running: true, numerator: 12, denomintor: 14
Running: false, numerator: 0, denomintor: 0
done!

参见

  • GearmanClient::doStatus

GearmanClient::ping

Send data to all job servers to see if they echo it back

说明

public bool GearmanClient::ping ( string $workload )

Sends some arbitrary data to all job servers to see if they echo it back. The data sent is not used or processed in any other way. Primarily used for testing and debugging.

参数

workload
Some arbitrary serialized data to be echo back

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

GearmanClient::removeOptions

Remove client options

说明

public bool GearmanClient::removeOptions ( int $options )

Removes (unsets) one or more options.

参数

options
The options to be removed (unset)

返回值

Always returns TRUE.

GearmanClient::returnCode

Get the last Gearman return code

说明

public int GearmanClient::returnCode ( void )

Returns the last Gearman return code.

参数

此函数没有参数。

返回值

A valid Gearman return code.

GearmanClient::runTasks

Run a list of tasks in parallel

说明

public bool GearmanClient::runTasks ( void )

For a set of tasks previously added with GearmanClient::addTask, GearmanClient::addTaskHigh, GearmanClient::addTaskLow, GearmanClient::addTaskBackground, GearmanClient::addTaskHighBackground, or GearmanClient::addTaskLowBackground, this call starts running the tasks in parallel.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::addTask

GearmanClient::setClientCallback

Callback function when there is a data packet for a task (deprecated)

说明

public void GearmanClient::setClientCallback ( callable $callback )

Sets the callback function for accepting data packets for a task. The callback function should take a single argument, a GearmanTask object.

Note:

This method has been replaced by class="methodname">GearmanClient::setDataCallback in the 0.6.0 release of the Gearman extension.

参数

callback
A function or method to call

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setDataCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setCompleteCallback

Set a function to be called on task completion

说明

public bool GearmanClient::setCompleteCallback ( callable $callback )

Use to set a function to be called when a GearmanTask is completed, or when GearmanJob::sendComplete is invoked by a worker (whichever happens first).

This callback executes only when executing a GearmanTask using GearmanClient::runTasks. It is not used for individual jobs.

参数

callback
A function to be called

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setContext

Set application context

说明

public bool GearmanClient::setContext ( string $context )

Sets an arbitrary string to provide application context that can later be retrieved by GearmanClient::context.

参数

context
Arbitrary context data

返回值

Always returns TRUE.

参见

  • GearmanClient::context

GearmanClient::setCreatedCallback

Set a callback for when a task is queued

说明

public bool GearmanClient::setCreatedCallback ( string $callback )

Sets a function to be called when a task is received and queued by the Gearman job server. The callback should accept a single argument, a GearmanTask object.

参数

callback
A function to call

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCompleteCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setData

Set application data (deprecated)

说明

public bool GearmanClient::setData ( string $data )

Sets some arbitrary application data that can later be retrieved by GearmanClient::data.

Note:

This method has been replaced by class="methodname">GearmanCient::setContext in the 0.6.0 release of the Gearman extension.

参数

data

返回值

Always returns TRUE.

参见

  • GearmanClient::data

GearmanClient::setDataCallback

Callback function when there is a data packet for a task

说明

public bool GearmanClient::setDataCallback ( callable $callback )

Sets the callback function for accepting data packets for a task. The callback function should take a single argument, a GearmanTask object.

参数

callback
A function or method to call

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setExceptionCallback

Set a callback for worker exceptions

说明

public bool GearmanClient::setExceptionCallback ( callable $callback )

Specifies a function to call when a worker for a task sends an exception.

参数

callback
Function to call when the worker throws an exception

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setFailCallback

Set callback for job failure

说明

public bool GearmanClient::setFailCallback ( callable $callback )

Sets the callback function to be used when a task does not complete successfully. The function should accept a single argument, a GearmanTask object.

参数

callback
A function to call

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setOptions

Set client options

说明

public bool GearmanClient::setOptions ( int $options )

Sets one or more client options.

参数

options
The options to be set

返回值

Always returns TRUE.

GearmanClient::setStatusCallback

Set a callback for collecting task status

说明

public bool GearmanClient::setStatusCallback ( callable $callback )

Sets a callback function used for getting updated status information from a worker. The function should accept a single argument, a GearmanTask object.

参数

callback
A function to call

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setWarningCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setTimeout

Set socket I/O activity timeout

说明

public bool GearmanClient::setTimeout ( int $timeout )

Sets the timeout for socket I/O activity.

参数

timeout
An interval of time in milliseconds

返回值

Always returns TRUE.

GearmanClient::setWarningCallback

Set a callback for worker warnings

说明

public bool GearmanClient::setWarningCallback ( callable $callback )

Sets a function to be called when a worker sends a warning. The callback should accept a single argument, a GearmanTask object.

参数

callback
A function to call

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWorkloadCallback

GearmanClient::setWorkloadCallback

Set a callback for accepting incremental data updates

说明

public bool GearmanClient::setWorkloadCallback ( callable $callback )

Sets a function to be called when a worker needs to send back data prior to job completion. A worker can do this when it needs to send updates, send partial results, or flush data during long running jobs. The callback should accept a single argument, a GearmanTask object.

参数

callback
A function to call

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::setDataCallback
  • GearmanClient::setCompleteCallback
  • GearmanClient::setCreatedCallback
  • GearmanClient::setExceptionCallback
  • GearmanClient::setFailCallback
  • GearmanClient::setStatusCallback
  • GearmanClient::setWarningCallback

GearmanClient::timeout

Get current socket I/O activity timeout value

说明

public int GearmanClient::timeout ( void )

Returns the timeout in milliseconds to wait for I/O activity.

参数

此函数没有参数。

返回值

Timeout in milliseconds to wait for I/O activity. A negative value means an infinite timeout.

参见

  • GearmanClient::setTimeout

简介

类摘要

GearmanJob

class GearmanJob {

/* 方法 */

public bool complete ( string $result )

public __construct ( void )

public bool data ( string $data )

public bool exception ( string $exception )

public bool fail ( void )

public string functionName ( void )

public string handle ( void )

public int returnCode ( void )

public bool sendComplete ( string $result )

public bool sendData ( string $data )

public bool sendException ( string $exception )

public bool sendFail ( void )

public bool sendStatus ( int $numerator , int $denominator )

public bool sendWarning ( string $warning )

public bool setReturn ( int $gearman_return_t )

public bool status ( int $numerator , int $denominator )

public string unique ( void )

public bool warning ( string $warning )

public string workload ( void )

public int workloadSize ( void )

}

GearmanJob::complete

Send the result and complete status (deprecated)

说明

public bool GearmanJob::complete ( string $result )

Sends result data and the complete status update for this job.

Note:

This method has been replaced by class="methodname">GearmanJob::sendComplete in the 0.6.0 release of the Gearman extension.

参数

result
Serialized result data.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::sendFail
  • GearmanJob::setReturn

GearmanJob::__construct

Create a GearmanJob instance

说明

public GearmanJob::__construct ( void )

Creates a GearmanJob instance representing a job the worker is to complete.

参数

此函数没有参数。

返回值

A GearmanJob object.

GearmanJob::data

Send data for a running job (deprecated)

说明

public bool GearmanJob::data ( string $data )

Sends data to the job server (and any listening clients) for this job.

Note:

This method has been replaced by class="methodname">GearmanJob::sendData in the 0.6.0 release of the Gearman extension.

参数

data
Arbitrary serialized data.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::workload
  • GearmanTask::data

GearmanJob::exception

Send exception for running job (deprecated)

说明

public bool GearmanJob::exception ( string $exception )

Sends the supplied exception when this job is running.

Note:

This method has been replaced by class="methodname">GearmanJob::sendException in the 0.6.0 release of the Gearman extension.

参数

exception
An exception description.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::setReturn
  • GearmanJob::sendStatus
  • GearmanJob::sendWarning

GearmanJob::fail

Send fail status (deprecated)

说明

public bool GearmanJob::fail ( void )

Sends failure status for this job, indicating that the job failed in a known way (as opposed to failing due to a thrown exception).

Note:

This method has been replaced by class="methodname">GearmanJob::sendFail in the 0.6.0 release of the Gearman extension.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::sendException
  • GearmanJob::setReturn
  • GearmanJob::sendStatus
  • GearmanJob::sendWarning

GearmanJob::functionName

Get function name

说明

public string GearmanJob::functionName ( void )

Returns the function name for this job. This is the function the work will execute to perform the job.

参数

此函数没有参数。

返回值

The name of a function.

参见

  • GearmanTask::function

GearmanJob::handle

Get the job handle

说明

public string GearmanJob::handle ( void )

Returns the opaque job handle assigned by the job server.

参数

此函数没有参数。

返回值

An opaque job handle.

参见

  • GearmanTask::jobHandle

GearmanJob::returnCode

Get last return code

说明

public int GearmanJob::returnCode ( void )

Returns the last return code issued by the job server.

参数

此函数没有参数。

返回值

A valid Gearman return code.

参见

  • GearmanTask::returnCode

GearmanJob::sendComplete

Send the result and complete status

说明

public bool GearmanJob::sendComplete ( string $result )

Sends result data and the complete status update for this job.

参数

result
Serialized result data.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::sendFail
  • GearmanJob::setReturn

GearmanJob::sendData

Send data for a running job

说明

public bool GearmanJob::sendData ( string $data )

Sends data to the job server (and any listening clients) for this job.

参数

data
Arbitrary serialized data.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::workload
  • GearmanTask::data

GearmanJob::sendException

Send exception for running job (exception)

说明

public bool GearmanJob::sendException ( string $exception )

Sends the supplied exception when this job is running.

参数

exception
An exception description.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::setReturn
  • GearmanJob::sendStatus
  • GearmanJob::sendWarning

GearmanJob::sendFail

Send fail status

说明

public bool GearmanJob::sendFail ( void )

Sends failure status for this job, indicating that the job failed in a known way (as opposed to failing due to a thrown exception).

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::sendException
  • GearmanJob::setReturn
  • GearmanJob::sendStatus
  • GearmanJob::sendWarning

GearmanJob::sendStatus

Send status

说明

public bool GearmanJob::sendStatus ( int $numerator , int $denominator )

Sends status information to the job server and any listening clients. Use this to specify what percentage of the job has been completed.

参数

numerator
The numerator of the precentage completed expressed as a fraction.

denominator
The denominator of the precentage completed expressed as a fraction.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::jobStatus
  • GearmanTask::taskDenominator
  • GearmanTask::taskNumerator

GearmanJob::sendWarning

Send a warning

说明

public bool GearmanJob::sendWarning ( string $warning )

Sends a warning for this job while it is running.

参数

warning
A warning message.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::sendComplete
  • GearmanJob::sendException
  • GearmanJob::sendFail

GearmanJob::setReturn

Set a return value

说明

public bool GearmanJob::setReturn ( int $gearman_return_t )

Sets the return value for this job, indicates how the job completed.

参数

gearman_return_t
A valid Gearman return value.

返回值

Description...

GearmanJob::status

Send status (deprecated)

说明

public bool GearmanJob::status ( int $numerator , int $denominator )

Sends status information to the job server and any listening clients. Use this to specify what percentage of the job has been completed.

Note:

This method has been replaced by class="methodname">GearmanJob::sendStatus in the 0.6.0 release of the Gearman extenstion.

参数

numerator
The numerator of the precentage completed expressed as a fraction.

denominator
The denominator of the precentage completed expressed as a fraction.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanClient::jobStatus
  • GearmanTask::taskDenominator
  • GearmanTask::taskNumerator

GearmanJob::unique

Get the unique identifier

说明

public string GearmanJob::unique ( void )

Returns the unique identifiter for this job. The identifier is assigned by the client.

参数

此函数没有参数。

返回值

An opaque unique identifier.

参见

  • GearmanClient::do
  • GearmanTask::uuid

GearmanJob::warning

Send a warning (deprecated)

说明

public bool GearmanJob::warning ( string $warning )

Sends a warning for this job while it is running.

Note:

This method has been replaced by class="methodname">GearmanJob::sendWarning in the 0.6.0 release of the Gearman extension.

参数

warning
A warning messages.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

参见

  • GearmanJob::sendComplete
  • GearmanJob::sendException
  • GearmanJob::sendFail

GearmanJob::workload

Get workload

说明

public string GearmanJob::workload ( void )

Returns the workload for the job. This is serialized data that is to be processed by the worker.

参数

此函数没有参数。

返回值

Serialized data.

参见

  • GearmanClient::do
  • GearmanJob::workloadSize

GearmanJob::workloadSize

Get size of work load

说明

public int GearmanJob::workloadSize ( void )

Returns the size of the job's work load (the data the worker is to process) in bytes.

参数

此函数没有参数。

返回值

The size in bytes.

参见

  • GearmanJob::workload

简介

类摘要

GearmanTask

class GearmanTask {

/* 方法 */

public __construct ( void )

public GearmanTask create ( void )

public string data ( void )

public int dataSize ( void )

public string function ( void )

public string functionName ( void )

public bool isKnown ( void )

public bool isRunning ( void )

public string jobHandle ( void )

public array recvData ( int $data_len )

public int returnCode ( void )

public int sendData ( string $data )

public int sendWorkload ( string $data )

public int taskDenominator ( void )

public int taskNumerator ( void )

public string unique ( void )

public string uuid ( void )

}

GearmanTask::__construct

Create a GearmanTask instance

说明

public GearmanTask::__construct ( void )

Creates a GearmanTask instance representing a task to be submitted to a job server.

参数

此函数没有参数。

返回值

A GearmanTask object.

GearmanTask::create

Create a task (deprecated)

说明

public GearmanTask GearmanTask::create ( void )

Returns a new GearmanTask object.

Note:

This method was removed in the 0.6.0 version of the Gearman extension.

参数

此函数没有参数。

返回值

A GearmanTask oject 或者在失败时返回 FALSE.

GearmanTask::data

Get data returned for a task

说明

public string GearmanTask::data ( void )

Returns data being returned for a task by a worker.

参数

此函数没有参数。

返回值

The serialized data, or FALSE if no data is present.

参见

  • GearmanTask::dataSize

GearmanTask::dataSize

Get the size of returned data

说明

public int GearmanTask::dataSize ( void )

Returns the size of the data being returned for a task.

参数

此函数没有参数。

返回值

The data size, or FALSE if there is no data.

参见

  • GearmanTask::data

GearmanTask::function

Get associated function name (deprecated)

说明

public string GearmanTask::function ( void )

Returns the name of the function this task is associated with, i.e., the function the Gearman worker calls.

Note:

This method has been replaced by class="methodname">GearmanTask::functionName in the 0.6.0 release of the Gearman extension.

参数

此函数没有参数。

返回值

A function name.

GearmanTask::functionName

Get associated function name

说明

public string GearmanTask::functionName ( void )

Returns the name of the function this task is associated with, i.e., the function the Gearman worker calls.

参数

此函数没有参数。

返回值

A function name.

GearmanTask::isKnown

Determine if task is known

说明

public bool GearmanTask::isKnown ( void )

Gets the status information for whether or not this task is known to the job server.

参数

此函数没有参数。

返回值

TRUE if the task is known, FALSE otherwise.

GearmanTask::isRunning

Test whether the task is currently running

说明

public bool GearmanTask::isRunning ( void )

Indicates whether or not this task is currently running.

参数

此函数没有参数。

返回值

TRUE if the task is running, FALSE otherwise.

GearmanTask::jobHandle

gearman_job_handle

Get the job handle

说明

public string GearmanTask::jobHandle ( void )

Returns the job handle for this task.

参数

此函数没有参数。

返回值

The opaque job handle.

参见

  • GearmanClient::doJobHandle

GearmanTask::recvData

Read work or result data into a buffer for a task

说明

public array GearmanTask::recvData ( int $data_len )

Warning

此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担 。

参数

data_len
Length of data to be read.

返回值

An array whose first element is the length of data read and the second is the data buffer. Returns FALSE if the read failed.

参见

  • GearmanTask::sendData

GearmanTask::returnCode

Get the last return code

说明

public int GearmanTask::returnCode ( void )

Returns the last Gearman return code for this task.

参数

此函数没有参数。

返回值

A valid Gearman return code.

参见

  • GearmanClient::returnCode

GearmanTask::sendData

Send data for a task (deprecated)

说明

public int GearmanTask::sendData ( string $data )

Warning

此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担 。

参数

data
Data to send to the worker.

返回值

The length of data sent, or FALSE if the send failed.

参见

  • GearmanTask::recvData

GearmanTask::sendWorkload

Send data for a task

说明

public int GearmanTask::sendWorkload ( string $data )

Warning

此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担 。

参数

data
Data to send to the worker.

返回值

The length of data sent, or FALSE if the send failed.

参见

  • GearmanTask::recvData

GearmanTask::taskDenominator

Get completion percentage denominator

说明

public int GearmanTask::taskDenominator ( void )

Returns the denominator of the percentage of the task that is complete expressed as a fraction.

参数

此函数没有参数。

返回值

A number between 0 and 100, or FALSE if cannot be determined.

参见

  • GearmanTask::taskNumerator

GearmanTask::taskNumerator

Get completion percentage numerator

说明

public int GearmanTask::taskNumerator ( void )

Returns the numerator of the percentage of the task that is complete expressed as a fraction.

参数

此函数没有参数。

返回值

A number between 0 and 100, or FALSE if cannot be determined.

参见

  • GearmanTask::taskDenominator

GearmanTask::unique

Get the unique identifier for a task

说明

public string GearmanTask::unique ( void )

Returns the unique identifier for this task. This is assigned by the GearmanClient, as opposed to the job handle which is set by the Gearman job server.

参数

此函数没有参数。

返回值

The unique identifier, or FALSE if no identifier is assigned.

参见

  • GearmanClient::do
  • GearmanClient::addTask

GearmanTask::uuid

Get the unique identifier for a task (deprecated)

说明

public string GearmanTask::uuid ( void )

Returns the unique identifier for this task. This is assigned by the GearmanClient, as opposed to the job handle which is set by the Gearman job server.

Note:

This method has been replaced by class="methodname">GearmanTask::unique in the 0.6.0 release of the Gearman extension.

参数

此函数没有参数。

返回值

The unique identifier, or FALSE if no identifier is assigned.

参见

  • GearmanClient::do
  • GearmanClient::addTask

简介

类摘要

GearmanWorker

class GearmanWorker {

/* 方法 */

public bool addFunction ( string $function_name , callable $function [, mixed &$context [, int $timeout ]] )

public bool addOptions ( int $option )

public bool addServer ([ string $host = 127.0.0.1 [, int $port = 4730 ]] )

public bool addServers ( string $servers = 127.0.0.1:4730 )

public void clone ( void )

public __construct ( void )

public bool echo ( string $workload )

public string error ( void )

public int getErrno ( void )

public int options ( void )

public bool register ( string $function_name [, int $timeout ] )

public bool removeOptions ( int $option )

public int returnCode ( void )

public bool setId ( string $id )

public bool setOptions ( int $option )

public bool setTimeout ( int $timeout )

public int timeout ( void )

public bool unregister ( string $function_name )

public bool unregisterAll ( void )

public bool wait ( void )

public bool work ( void )

}

GearmanWorker::addFunction

Register and add callback function

说明

public bool GearmanWorker::addFunction ( string $function_name , callable $function [, mixed &$context [, int $timeout ]] )

Registers a function name with the job server and specifies a callback corresponding to that function. Optionally specify extra application context data to be used when the callback is called and a timeout.

参数

function_name
The name of a function to register with the job server

function
A callback that gets called when a job for the registered function name is submitted

context
A reference to arbitrary application context data that can be modified by the worker function

timeout
An interval of time in seconds

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 Simple worker making use of extra application context data

<?php

# get a gearman worker
$worker= new GearmanWorker(); 

# add the default server (localhost)
$worker->addServer(); 

# define a variable to hold application data
$count= 0; 

# add the "reverse" function
$worker->addFunction("reverse", "reverse_cb", $count);

# start the worker
while ($worker->work());

function reverse_cb($job, &$count) 
{ 
  $count++; 
  return "$count: " . strrev($job->workload()); 
} 

?>

Running a client that submits two jobs for the reverse function would have output similar to the following:

1: olleh
2: dlrow

参见

  • GearmanClient::do

GearmanWorker::addOptions

Add worker options

说明

public bool GearmanWorker::addOptions ( int $option )

Adds one or more options to the options previously set.

参数

option
The options to be added

返回值

Always returns TRUE.

参见

  • GearmanWorker::options
  • GearmanClient::setOptions
  • GearmanClient::removeOptions

GearmanWorker::addServer

Add a job server

说明

public bool GearmanWorker::addServer ([ string $host = 127.0.0.1 [, int $port = 4730 ]] )

Adds a job server to this worker. This goes into a list of servers than can be used to run jobs. No socket I/O happens here.

参数

host
任务服务器主机名。

port
任务服务器端口号。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 Add alternate Gearman servers

<?php
$worker= new GearmanWorker(); 
$worker->addServer("10.0.0.1"); 
$worker->addServer("10.0.0.2", 7003);
?>

参见

  • GearmanWorker::addServers

GearmanWorker::addServers

Add job servers

说明

public bool GearmanWorker::addServers ( string $servers = 127.0.0.1:4730 )

Adds one or more job servers to this worker. These go into a list of servers that can be used to run jobs. No socket I/O happens here.

参数

servers
A comma separated list of job servers in the format host:port. If no port is specified, it defaults to 4730.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 Add two job servers

<?php

$worker= new GearmanWorker(); 
$worker->addServers("10.0.0.1,10.0.0.2:7003");

?>

参见

  • GearmanWorker::addServer

GearmanWorker::clone

Create a copy of the worker

说明

public void GearmanWorker::clone ( void )

Creates a copy of the worker.

参数

此函数没有参数。

返回值

A GearmanWorker object

GearmanWorker::__construct

Create a GearmanWorker instance

说明

public GearmanWorker::__construct ( void )

Creates a GearmanWorker instance representing a worker that connects to the job server and accepts tasks to run.

参数

此函数没有参数。

返回值

A GearmanWorker object

参见

  • GearmanWorker::clone

GearmanWorker::echo

Test job server response

说明

public bool GearmanWorker::echo ( string $workload )

Sends data to all job servers to see if they echo it back. This is a test function to see if job servers are responding properly.

参数

workload
Arbitrary serialized data

返回值

Standard Gearman return value.

参见

  • GearmanClient::echo

GearmanWorker::error

Get the last error encountered

说明

public string GearmanWorker::error ( void )

Returns an error string for the last error encountered.

参数

此函数没有参数。

返回值

An error string.

参见

  • GearmanWorker::getErrno

GearmanWorker::getErrno

Get errno

说明

public int GearmanWorker::getErrno ( void )

Returns the value of errno in the case of a GEARMAN_ERRNO return value.

参数

此函数没有参数。

返回值

A valid errno.

参见

  • GearmanWorker::error

GearmanWorker::options

Get worker options

说明

public int GearmanWorker::options ( void )

Gets the options previously set for the worker.

参数

此函数没有参数。

返回值

The options currently set for the worker.

参见

  • GearmanWorker::setOptions

GearmanWorker::register

Register a function with the job server

说明

public bool GearmanWorker::register ( string $function_name [, int $timeout ] )

Registers a function name with the job server with an optional timeout. The timeout specifies how many seconds the server will wait before marking a job as failed. If the timeout is set to zero, there is no timeout.

参数

function_name
The name of a function to register with the job server

timeout
An interval of time in seconds

返回值

A standard Gearman return value.

参见

  • GearmanWorker::unregister
  • GearmanWorker::unregisterAll

GearmanWorker::removeOptions

Remove worker options

说明

public bool GearmanWorker::removeOptions ( int $option )

Removes (unsets) one or more worker options.

参数

option
The options to be removed (unset)

返回值

Always returns TRUE.

参见

  • GearmanWorker::options
  • GearmanWorker::setOptions
  • GearmanWorker::addOptions

GearmanWorker::returnCode

Get last Gearman return code

说明

public int GearmanWorker::returnCode ( void )

Returns the last Gearman return code.

参数

此函数没有参数。

返回值

A valid Gearman return code.

参见

  • GearmanWorker::error
  • GearmanWorker::getErrno

GearmanWorker::setId

Give the worker an identifier so it can be tracked when asking gearmand for the list of available workers

说明

public bool GearmanWorker::setId ( string $id )

Assigns the worker an identifier.

参数

id
A string identifier.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 GearmanWorker::setId example

Set an identifier for a simple worker.

<?php
$worker= new GearmanWorker();
$worker->setId('test');
?>

以上例程的输出类似于:

Run the following command:
gearadmin --workers

Output:
30 ::3a3a:3361:3361:3a33%976303667 - : test

GearmanWorker::setOptions

Set worker options

说明

public bool GearmanWorker::setOptions ( int $option )

Sets one or more options to the supplied value.

参数

option
The options to be set

返回值

Always returns TRUE.

参见

  • GearmanWorker::options
  • GearmanWorker::addOptions
  • GearmanWorker::removeOptions
  • GearmanClient::setOptions

GearmanWorker::setTimeout

Set socket I/O activity timeout

说明

public bool GearmanWorker::setTimeout ( int $timeout )

Sets the interval of time to wait for socket I/O activity.

参数

timeout
An interval of time in milliseconds. A negative value indicates an infinite timeout.

返回值

Always returns TRUE.

范例

示例 #1 A simple worker with a 5 second timeout

<?php

echo "Starting\n";

# Create our worker object.
$gmworker= new GearmanWorker();

# Add default server (localhost).
$gmworker->addServer();

# Register function "reverse" with the server.
$gmworker->addFunction("reverse", "reverse_fn");

# Set the timeout to 5 seconds
$gmworker->setTimeout(5000);

echo "Waiting for job...\n";
while(@$gmworker->work() || $gmworker->returnCode() == GEARMAN_TIMEOUT)
{
  if ($gmworker->returnCode() == GEARMAN_TIMEOUT)
  {
    # Normally one would want to do something useful here ...
    echo "Timeout. Waiting for next job...\n";
    continue;
  }

  if ($gmworker->returnCode() != GEARMAN_SUCCESS)
  {
    echo "return_code: " . $gmworker->returnCode() . "\n";
    break;
  }
}

echo "Done\n";

function reverse_fn($job)
{
  return strrev($job->workload());
}

?>

Running the worker with no submitted jobs will generate output that looks like the following:

Starting
Waiting for job...
Timeout. Waiting for next job...
Timeout. Waiting for next job...
Timeout. Waiting for next job...

参见

  • GearmanWorker::timeout

GearmanWorker::timeout

Get socket I/O activity timeout

说明

public int GearmanWorker::timeout ( void )

Returns the current time to wait, in milliseconds, for socket I/O activity.

参数

此函数没有参数。

返回值

A time period is milliseconds. A negative value indicates an infinite timeout.

参见

  • GearmanWorker::setTimeout

GearmanWorker::unregister

Unregister a function name with the job servers

说明

public bool GearmanWorker::unregister ( string $function_name )

Unregisters a function name with the job servers ensuring that no more jobs (for that function) are sent to this worker.

参数

function_name
The name of a function to register with the job server

返回值

A standard Gearman return value.

参见

  • GearmanWorker::register
  • GearmanWorker::unregisterAll

GearmanWorker::unregisterAll

Unregister all function names with the job servers

说明

public bool GearmanWorker::unregisterAll ( void )

Unregisters all previously registered functions, ensuring that no more jobs are sent to this worker.

参数

此函数没有参数。

返回值

A standard Gearman return value.

参见

  • GearmanWorker::register
  • GearmanWorker::unregister

GearmanWorker::wait

Wait for activity from one of the job servers

说明

public bool GearmanWorker::wait ( void )

Causes the worker to wait for activity from one of the Gearman job servers when operating in non-blocking I/O mode. On failure, issues a E_WARNING with the last Gearman error encountered.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 Running worker in non-blocking mode

<?php

echo "Starting\n";

# Create our worker object
$worker= new GearmanWorker();

# Make the worker non-blocking
$worker->addOptions(GEARMAN_WORKER_NON_BLOCKING); 

# Add the default server (localhost, port 4730)
$worker->addServer(); 

# Add our reverse function
$worker->addFunction('reverse', 'reverse_fn');

# Try to grab a job
while (@$worker->work() ||
       $worker->returnCode() == GEARMAN_IO_WAIT ||
       $worker->returnCode() == GEARMAN_NO_JOBS)
{
  if ($worker->returnCode() == GEARMAN_SUCCESS)
    continue;

  echo "Waiting for next job...\n";
  if (!@$worker->wait()) 
  { 
    if ($worker->returnCode() == GEARMAN_NO_ACTIVE_FDS) 
    { 
      # We are not connected to any servers, so wait a bit before 
      # trying to reconnect. 
      sleep(5); 
      continue; 
    } 
    break; 
  } 
} 

echo "Worker Error: " . $worker->error() . "\n";

function reverse_fn($job)
{
  return strrev($job->workload());
}


?>

参见

  • GearmanWorker::work

GearmanWorker::work

Wait for and perform jobs

说明

public bool GearmanWorker::work ( void )

Waits for a job to be assigned and then calls the appropriate callback function. Issues an E_WARNING with the last Gearman error if the return code is not one of GEARMAN_SUCCESS, GEARMAN_IO_WAIT, or GEARMAN_WORK_FAIL.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 GearmanWorker::work example

<?php

# create the worker
$worker = new GearmanWorker(); 

# add the default job server (localhost)
$worker->addServer(); 

# add the reverse function
$worker->addFunction("reverse", "my_reverse_function"); 

# start te worker listening for job submissions
while ($worker->work()); 
 
function my_reverse_function($job) 
{ 
  return strrev($job->workload()); 
}

?>

参见

  • GearmanWorker::addFunction

简介

类摘要

GearmanException

class GearmanException extends Exception {

/* 继承的属性 */

protected string $message ;

protected int $code ;

protected string $file ;

protected int $line ;

/* 方法 */

/* 继承的方法 */

final public string Exception::getMessage ( void )

final public Throwable Exception::getPrevious ( void )

final public int Exception::getCode ( void )

final public string Exception::getFile ( void )

final public int Exception::getLine ( void )

final public array Exception::getTrace ( void )

final public string Exception::getTraceAsString ( void )

public string Exception::__toString ( void )

final private void Exception::__clone ( void )

}