Skip to content

Commit

Permalink
Add Swoole Tracker leak tool (#2696)
Browse files Browse the repository at this point in the history
* add Swoole Tracker leak tool

* Update phpstan.neon

* update tips

* Update phpstan.neon

* Update CHANGELOG-2.0.md

Co-authored-by: 李铭昕 <715557344@qq.com>
  • Loading branch information
sy-records and limingxinleo committed Oct 21, 2020
1 parent 1e6b876 commit ad66804
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Aspect/OnRequestAspect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\SwooleTracker\Aspect;

use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\HttpServer\Server;
use Psr\Container\ContainerInterface;
use function trackerHookMalloc;

class OnRequestAspect extends AbstractAspect
{
public $classes = [
Server::class . '::onRequest',
];

/**
* @var ContainerInterface
*/
protected $container;

public function __construct(ContainerInterface $container)
{
$this->container = $container;
}

public function process(ProceedingJoinPoint $proceedingJoinPoint)
{
if (function_exists('trackerHookMalloc')) {
trackerHookMalloc();
}
return $proceedingJoinPoint->process();
}
}

0 comments on commit ad66804

Please sign in to comment.