Commit 3d09726e authored by Liu lu's avatar Liu lu

异步日志调整

parent 14703492
......@@ -6,6 +6,7 @@ namespace Meibuyu\Micro\Handler\LogTrace;
use Meibuyu\Micro\Handler\RedisQueueBatchHandler;
use Meibuyu\Micro\Model\LogTrace;
use Hyperf\DbConnection\Db;
use Hyperf\Redis\Redis;
class LogTraceQueue extends RedisQueueBatchHandler
{
......@@ -16,7 +17,7 @@ class LogTraceQueue extends RedisQueueBatchHandler
return env('APP_NAME').':LogTraceQueue';
}
protected function specifyRedisServer()
protected function specifyRedisServer():Redis
{
$redis = redis();
$redis->select(0);
......
......@@ -2,19 +2,19 @@
namespace Meibuyu\Micro\Handler;
use Hyperf\Redis\Redis;
abstract class RedisQueueBatchHandler
{
/**
* 重试次数
*/
protected $retrys=0;
protected $retry=0;
protected $queue_name;
/**
* @var \Hyperf\Redis\Redis
* @var Redis
*/
protected $redis;
......@@ -56,7 +56,7 @@ abstract class RedisQueueBatchHandler
//批处理具体逻辑
abstract protected function batchDeal($data);
abstract protected function specifyQueueName();
abstract protected function specifyRedisServer();
abstract protected function specifyRedisServer() : Redis;
public function consume()
......@@ -86,16 +86,16 @@ abstract class RedisQueueBatchHandler
//错误码为100 重新推到队列
if($exception->getCode()==self::ERROR_RETRY_CODE){
if($this->retrys<self::MAX_RETRY_TIMES){ //重试次数不超过3次
if($this->retry<self::MAX_RETRY_TIMES){ //重试次数不超过3次
$this->backToQueue($arr);
$this->retrys++;
$this->retry++;
}else{
$this->retrys = 0; //重置当前次数
$this->retry = 0; //重置当前次数
$this->errorWriteToFile($formatArr,$exception);
}
}else{
$this->retrys = 0;
$this->retry = 0;
$this->errorWriteToFile($formatArr,$exception);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment