Commit 5ab1c85f authored by Liu lu's avatar Liu lu

异步协程与异步日志批处理

parent 65ba2ba9
...@@ -12,7 +12,7 @@ class LogTraceQueue extends RedisQueueBatchHandler ...@@ -12,7 +12,7 @@ class LogTraceQueue extends RedisQueueBatchHandler
protected function specifyQueueName() protected function specifyQueueName()
{ {
$this->queue_name = 'LogTraceQueue'; $this->queue_name = env('APP_NAME').':LogTraceQueue';
} }
/** /**
...@@ -28,7 +28,7 @@ class LogTraceQueue extends RedisQueueBatchHandler ...@@ -28,7 +28,7 @@ class LogTraceQueue extends RedisQueueBatchHandler
$updateArr[$arr['request_id']]['is_completed'] = $arr['is_completed']; $updateArr[$arr['request_id']]['is_completed'] = $arr['is_completed'];
$process_info = isset($updateArr[$arr['request_id']]['process_info'])? $process_info = isset($updateArr[$arr['request_id']]['process_info'])?
($updateArr[$arr['request_id']]['process_info']."\n\n"):''; $updateArr[$arr['request_id']]['process_info']:'';
$updateArr[$arr['request_id']]['process_info'] = $process_info.$arr['process_info']; $updateArr[$arr['request_id']]['process_info'] = $process_info.$arr['process_info'];
...@@ -44,7 +44,7 @@ class LogTraceQueue extends RedisQueueBatchHandler ...@@ -44,7 +44,7 @@ class LogTraceQueue extends RedisQueueBatchHandler
if(empty($originLogs[$item['request_id']])) return $item; if(empty($originLogs[$item['request_id']])) return $item;
$item['process_info'] = $originLogs[$item['request_id']]."\n\n".$item['process_info']; $item['process_info'] = $originLogs[$item['request_id']].$item['process_info'];
return $item; return $item;
},$updateArr); },$updateArr);
......
...@@ -71,7 +71,7 @@ abstract class RedisQueueBatchHandler ...@@ -71,7 +71,7 @@ abstract class RedisQueueBatchHandler
$arr = $redis->lRange($this->queue_name,0,self::BATCH_DEAL_NUM-1); $arr = $redis->lRange($this->queue_name,0,self::BATCH_DEAL_NUM-1);
//取完 从队列删掉 //取完 从队列删掉
$redis->lTrim($this->queue_name,self::BATCH_DEAL_NUM,-1); $redis->lTrim($this->queue_name,count($arr),-1);
//数据格式化 //数据格式化
$formatArr = array_map(function ($item){ $formatArr = array_map(function ($item){
return json_decode($item,true); return json_decode($item,true);
......
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