uoload
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @date 2021/6/24 16:40
|
||||
*/
|
||||
|
||||
namespace Tests;
|
||||
|
||||
class TestHandler extends \WorkerManQueue\Handler\JobHandler
|
||||
{
|
||||
/**
|
||||
* 失败回调方法
|
||||
* @param \WorkerManQueue\Job $job 任务
|
||||
* @param string $func 执行的方法
|
||||
* @param array $data 参数
|
||||
* @return mixed
|
||||
*/
|
||||
public function failed(\WorkerManQueue\Job $job, $func, $data)
|
||||
{
|
||||
\WorkerManQueue\Helpers\Log::info('failed run handler -- func: ' . $func . ' -- params: ' . json_encode($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务成功回调
|
||||
* @param \WorkerManQueue\Job $job 任务
|
||||
* @param string $func 执行的方法
|
||||
* @param array $data 参数
|
||||
* @return mixed
|
||||
*/
|
||||
public function success(\WorkerManQueue\Job $job, $func, $data)
|
||||
{
|
||||
\WorkerManQueue\Helpers\Log::info('success run handler -- func: ' . $func . ' -- params: ' . json_encode($data));
|
||||
}
|
||||
|
||||
|
||||
public function test(\WorkerManQueue\Job $job, $data)
|
||||
{
|
||||
$res = 'success';
|
||||
\WorkerManQueue\Helpers\Log::info('run handler -- func: test -- params: ' . json_encode($data) . '; result : ' . var_export($res, true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
require dirname(__DIR__)."/vendor/autoload.php";
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'log' => [
|
||||
'logRoot' => __DIR__ . '/../runtime/log',
|
||||
'fileName' => '\q\u\e\u\e_Y-m-d.\l\o\g',
|
||||
],
|
||||
|
||||
'connectList' => [
|
||||
'Redis' => [
|
||||
'class' => '\\WorkerManQueue\\Connection\\Redis\\Redis',
|
||||
'config' => [
|
||||
'popTimeout' => 3, // pop阻塞的超时时长 s
|
||||
'host' => '127.0.0.1', // 数据库地址
|
||||
'port' => 6379, // 数据库端口
|
||||
'db' => 0, // 库
|
||||
'password' => null, // 密码
|
||||
'connTimeout' => 1, // 链接超时
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
'currentConnect' => 'Redis',
|
||||
];
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require __DIR__ . "/bootstrap.php";
|
||||
require __DIR__ . "/TestHandler.php";
|
||||
|
||||
$config = include __DIR__ . '/config.php';
|
||||
|
||||
$queue = \WorkerManQueue\Queue::getInstance('Redis', $config);
|
||||
|
||||
use Tests\TestHandler;
|
||||
|
||||
for ($i = 0; $i <= 100; $i++) {
|
||||
$r = $queue->pushOn(new TestHandler(), 'test', ['test' => $i], 'queue');
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
require __DIR__."/bootstrap.php";
|
||||
|
||||
$config = include __DIR__.'/config.php';
|
||||
|
||||
$worker = new \WorkerManQueue\Worker($config);
|
||||
|
||||
$worker->run();
|
||||
Reference in New Issue
Block a user