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
63750319
Commit
63750319
authored
Mar 11, 2022
by
Liu lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
协程异步兼容hyperf 版本1
parent
959e21a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
AsyncCoroutineAspect.php
src/Aspect/AsyncCoroutineAspect.php
+2
-1
LogTraceHandler.php
src/Handler/LogTrace/LogTraceHandler.php
+1
-1
No files found.
src/Aspect/AsyncCoroutineAspect.php
View file @
63750319
...
...
@@ -29,7 +29,7 @@ class AsyncCoroutineAspect extends AbstractAspect
// 切面切入后,执行对应的方法会由此来负责
// $proceedingJoinPoint 为连接点,通过该类的 process() 方法调用原方法并获得结果
// 在调用前进行某些处理
return
Coroutine
::
create
(
function
()
use
(
$proceedingJoinPoint
){
Coroutine
::
defer
(
function
()
use
(
$proceedingJoinPoint
){
try
{
LogTraceHandler
::
recordProcess
(
'投递到子协程任务,id:'
.
Coroutine
::
id
()
...
...
@@ -48,6 +48,7 @@ class AsyncCoroutineAspect extends AbstractAspect
LogTraceHandler
::
recordProcess
(
$exception
,
true
);
}
});
return
Coroutine
::
id
();
}
...
...
src/Handler/LogTrace/LogTraceHandler.php
View file @
63750319
...
...
@@ -69,7 +69,7 @@ class LogTraceHandler
private
static
function
getRequestId
(
$isInAsyncCoroutine
=
false
)
{
$workId
=
posix_getpid
();
$cid
=
$isInAsyncCoroutine
?
Coroutine
::
parentId
(
Coroutine
::
id
())
:
Coroutine
::
id
();
$cid
=
Coroutine
::
id
();
if
(
!
$cid
)
throw
new
\Exception
(
'无法使用协程标记录日志'
);
return
container
(
Server
::
class
)
->
stats
()[
'start_time'
]
.
$workId
.
$cid
;
}
...
...
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