Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-micro
Commits
3d09726e
Commit
3d09726e
authored
Apr 28, 2022
by
Liu lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步日志调整
parent
14703492
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
LogTraceQueue.php
src/Handler/LogTrace/LogTraceQueue.php
+2
-1
RedisQueueBatchHandler.php
src/Handler/RedisQueueBatchHandler.php
+8
-8
No files found.
src/Handler/LogTrace/LogTraceQueue.php
View file @
3d09726e
...
...
@@ -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
);
...
...
src/Handler/RedisQueueBatchHandler.php
View file @
3d09726e
...
...
@@ -2,19 +2,19 @@
namespace
Meibuyu\Micro\Handler
;
use
Hyperf\Redis\Redis
;
abstract
class
RedisQueueBatchHandler
{
/**
* 重试次数
*/
protected
$retry
s
=
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
->
retry
s
<
self
::
MAX_RETRY_TIMES
){
//重试次数不超过3次
if
(
$this
->
retry
<
self
::
MAX_RETRY_TIMES
){
//重试次数不超过3次
$this
->
backToQueue
(
$arr
);
$this
->
retry
s
++
;
$this
->
retry
++
;
}
else
{
$this
->
retry
s
=
0
;
//重置当前次数
$this
->
retry
=
0
;
//重置当前次数
$this
->
errorWriteToFile
(
$formatArr
,
$exception
);
}
}
else
{
$this
->
retry
s
=
0
;
$this
->
retry
=
0
;
$this
->
errorWriteToFile
(
$formatArr
,
$exception
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment