本文整理汇总了PHP中GearmanWorker::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP GearmanWorker::setId方法的具体用法?PHP GearmanWorker::setId怎么用?PHP GearmanWorker::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GearmanWorker
的用法示例。
在下文中一共展示了GearmanWorker::setId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CliDi
/**
* Read auto-loader
*/
include __DIR__ . '/config/loader.php';
/**
* Read the configuration
*/
$config = (include __DIR__ . '/config/config.php');
/**
* Read the services
*/
$di = new CliDi();
include __DIR__ . '/config/services.php';
/**
* Create a console application
*/
$console = new ConsoleApp($di);
$worker = new GearmanWorker();
$worker->setId(sha1(date("d.m.Y H:i:s")));
$worker->addServer('192.168.77.56', 4730);
$worker->addFunction("send_metrix_calc", function ($job) use(&$console, &$di) {
$di->set('workerJob', new MetrixResponse($di, $job, new FileAdapter(__DIR__ . "/logs/workjob_" . date("d-m-Y") . ".log")));
$arguments = json_decode($job->workload(), true);
$console->setDi($di);
$console->handle($arguments);
});
while ($worker->work()) {
if (GEARMAN_SUCCESS != $worker->returnCode()) {
echo "Worker failed: " . $worker->error() . "\n";
}
}