大网数据广告活动
PHP 语言与运行手册

The GearmanClient class

· 52CE 我爱测

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.

The GearmanClient class

(PECL gearman >= 0.5.0)

Introduction

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.

Class synopsis

class GearmanClient {
/* Methods */
public function __construct()
public function addOptions(int $option): bool
public function addServer(string $host = null, int $port = 0, bool $setupExceptionHandler = true): bool
public function addServers(string $servers = null, bool $setupExceptionHandler = true): bool
public function addTask(
    string $function_name,
    string|int|float $workload,
    mixed $context = null,
    ?string $unique_key = null
): GearmanTask|false
public function addTaskBackground(
    string $function_name,
    string|int|float $workload,
    mixed $context = null,
    ?string $unique_key = null
): GearmanTask|false
public function addTaskHigh(
    string $function_name,
    string|int|float $workload,
    mixed $context = null,
    ?string $unique_key = null
): GearmanTask|false
public function addTaskHighBackground(
    string $function_name,
    string|int|float $workload,
    mixed $context = null,
    ?string $unique_key = null
): GearmanTask|false
public function addTaskLow(
    string $function_name,
    string|int|float $workload,
    mixed $context = null,
    ?string $unique_key = null
): GearmanTask|false
public function addTaskLowBackground(
    string $function_name,
    string|int|float $workload,
    mixed $context = null,
    ?string $unique_key = null
): GearmanTask|false
public function addTaskStatus(string $job_handle, mixed $context = null): GearmanTask|false
public function clearCallbacks(): bool
public function context(): string
public function doBackground(string $function, string $workload, ?string $unique = null): string
public function doHigh(string $function, string $workload, ?string $unique = null): string
public function doHighBackground(string $function, string $workload, ?string $unique = null): string
public function doJobHandle(): string
public function doLow(string $function, string $workload, ?string $unique = null): string
public function doLowBackground(string $function, string $workload, ?string $unique = null): string
public function doNormal(string $function, string $workload, ?string $unique = null): string
public function doStatus(): array
public function error(): string|false
public function getErrno(): int
public function jobStatus(string $job_handle): array
public function ping(string $workload): bool
public function removeOptions(int $option): bool
public function returnCode(): int
public function runTasks(): bool
public function setCompleteCallback(callable $callback): bool
public function setContext(string $data): bool
public function setCreatedCallback(callable $callback): bool
public function setDataCallback(callable $callback): bool
public function setExceptionCallback(callable $callback): bool
public function setFailCallback(callable $callback): bool
public function setOptions(int $option): bool
public function setStatusCallback(callable $callback): bool
public function setTimeout(int $timeout): bool
public function setWarningCallback(callable $callback): bool
public function setWorkloadCallback(callable $callback): bool
public function timeout(): int
public function wait(): bool
}

Table of Contents

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。