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

异步日志调整

parent 14703492
...@@ -6,6 +6,7 @@ namespace Meibuyu\Micro\Handler\LogTrace; ...@@ -6,6 +6,7 @@ namespace Meibuyu\Micro\Handler\LogTrace;
use Meibuyu\Micro\Handler\RedisQueueBatchHandler; use Meibuyu\Micro\Handler\RedisQueueBatchHandler;
use Meibuyu\Micro\Model\LogTrace; use Meibuyu\Micro\Model\LogTrace;
use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Db;
use Hyperf\Redis\Redis;
class LogTraceQueue extends RedisQueueBatchHandler class LogTraceQueue extends RedisQueueBatchHandler
{ {
...@@ -16,7 +17,7 @@ class LogTraceQueue extends RedisQueueBatchHandler ...@@ -16,7 +17,7 @@ class LogTraceQueue extends RedisQueueBatchHandler
return env('APP_NAME').':LogTraceQueue'; return env('APP_NAME').':LogTraceQueue';
} }
protected function specifyRedisServer() protected function specifyRedisServer():Redis
{ {
$redis = redis(); $redis = redis();
$redis->select(0); $redis->select(0);
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
namespace Meibuyu\Micro\Handler; namespace Meibuyu\Micro\Handler;
use Hyperf\Redis\Redis;
abstract class RedisQueueBatchHandler abstract class RedisQueueBatchHandler
{ {
/** /**
* 重试次数 * 重试次数
*/ */
protected $retrys=0; protected $retry=0;
protected $queue_name; protected $queue_name;
/** /**
* @var \Hyperf\Redis\Redis * @var Redis
*/ */
protected $redis; protected $redis;
...@@ -56,7 +56,7 @@ abstract class RedisQueueBatchHandler ...@@ -56,7 +56,7 @@ abstract class RedisQueueBatchHandler
//批处理具体逻辑 //批处理具体逻辑
abstract protected function batchDeal($data); abstract protected function batchDeal($data);
abstract protected function specifyQueueName(); abstract protected function specifyQueueName();
abstract protected function specifyRedisServer(); abstract protected function specifyRedisServer() : Redis;
public function consume() public function consume()
...@@ -86,16 +86,16 @@ abstract class RedisQueueBatchHandler ...@@ -86,16 +86,16 @@ abstract class RedisQueueBatchHandler
//错误码为100 重新推到队列 //错误码为100 重新推到队列
if($exception->getCode()==self::ERROR_RETRY_CODE){ 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->backToQueue($arr);
$this->retrys++; $this->retry++;
}else{ }else{
$this->retrys = 0; //重置当前次数 $this->retry = 0; //重置当前次数
$this->errorWriteToFile($formatArr,$exception); $this->errorWriteToFile($formatArr,$exception);
} }
}else{ }else{
$this->retrys = 0; $this->retry = 0;
$this->errorWriteToFile($formatArr,$exception); $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