moonspot/gearman
Composer 安装命令:
composer require moonspot/gearman
包简介
PHP library for interfacing with Gearmand
README 文档
README
About
Moonspot\Gearman is a package for interfacing with Gearman. Gearman is a system to farm out work to other machines, dispatching function calls to machines that are better suited to do work, to do work in parallel, to load balance lots of function calls, or to call functions between languages.
Installation
$ composer require moonspot/gearman
Examples
Client
<?php require __DIR__ . '/vendor/autoload.php'; use Moonspot\Gearman\Client; use Moonspot\Gearman\Set; use Moonspot\Gearman\Task; $client = new Client('localhost'); $set = new Set(); $task = new Task('Reverse_String', 'foobar'); $task->attachCallback( function ($func, $handle, $result) { print_r($result); } ); $set->addTask($task); $client->runSet($set);
Job
<?php namespace App\Gearman; use Moonspot\Gearman\Job\Common; class ReverseString extends Common { public function run($workload) { return strrev($workload); } }
Worker
For easiest use, use GearmanManager for running workers. See: https://github.com/brianlmoon/GearmanManager
<?php require __DIR__ . '/vendor/autoload.php'; use Moonspot\Gearman\Worker; $worker = new Worker('localhost'); $worker->addAbility('Reverse_String'); $worker->beginWork();
Functional Tests
To run the functional tests, docker is required. Run a gearmand in docker with a command like:
docker run -d -p 4730:4730 --rm \
--name gearmand \
artefactual/gearmand:latest
Once that is running, run the tests with the functional group flag.
./vendor/bin/phpunit --group=functional
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2025-11-09