Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
shellvon committed Oct 21, 2017
1 parent 84cad0d commit 36325af
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
namespace PHPSTORM_META {
override( \PG\AOP\MI::getObject(0), type(0));
}
44 changes: 21 additions & 23 deletions src/Base/AOPFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,26 @@ protected static function getDBProxy(IProxy $proxy, $coreBase)
}

/**
* 获取数据库Mysql/Redis池的协程.
* 获取协程redis
*
* @param IPoolCoroutine $coroutine
* @param Core $coreBase
* @param CoroutineRedisProxy $redisPoolCoroutine Redis协程辅助类实例
* @param Core $coreBase Core实例(通常为Controller实例)
*
* @return Wrapper
* @return Wrapper|CoroutineRedisProxy AOP包装的CoroutineRedisProxy切片实例
*/
protected static function getDBPoolCoroutine(IPoolCoroutine $coroutine, $coreBase)
public static function getRedisPoolCoroutine(CoroutineRedisProxy $redisPoolCoroutine, $coreBase)
{
$coroutineWrapper = new Wrapper($coroutine);
$coroutineWrapper->registerOnBefore(function($method, $arguments) use ($coreBase) {
$aopRedisPoolCoroutine = new Wrapper($redisPoolCoroutine);
$aopRedisPoolCoroutine->registerOnBefore(function ($method, $arguments) use ($coreBase) {
$context = $coreBase->getContext();
array_unshift($arguments, $context);
return [
$data = [
'method' => $method,
'arguments' => $arguments,
];
return $data;
});
return $coroutineWrapper;
}

/**
* 获取协程redis
*
* @param CoroutineRedisProxy $redisPoolCoroutine Redis协程辅助类实例
* @param Core $coreBase Core实例(通常为Controller实例)
*
* @return Wrapper|CoroutineRedisProxy AOP包装的CoroutineRedisProxy切片实例
*/
public static function getRedisPoolCoroutine(CoroutineRedisProxy $redisPoolCoroutine, $coreBase)
{
return static::getDBPoolCoroutine($redisPoolCoroutine, $coreBase);
return $aopRedisPoolCoroutine;
}

/**
Expand All @@ -111,7 +99,17 @@ public static function getRedisPoolCoroutine(CoroutineRedisProxy $redisPoolCorou
*/
public static function getMysqlPoolCoroutine(MysqlAsynPool $mysqlPoolCoroutine, $coreBase)
{
return static::getDBPoolCoroutine($mysqlPoolCoroutine, $coreBase);
$aopMysqlPoolCoroutine = new Wrapper($mysqlPoolCoroutine);
$aopMysqlPoolCoroutine->registerOnBefore(function ($method, $arguments) use ($coreBase) {
$context = $coreBase->getContext();
$arguments[] = $context;
$data = [
'method' => $method,
'arguments' => $arguments,
];
return $data;
});
return $aopMysqlPoolCoroutine;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Coroutine/IPoolCoroutine.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* Created by shellvon.
* 标记协程池.
*
* @author : shellvon<iamshellvon@gmail.com>
* @author camera360_server@camera360.com
* @date : 2017/9/30
* @time : 下午2:43
* @version 1.0
Expand All @@ -12,7 +12,7 @@
namespace PG\MSF\Coroutine;

/**
* Interface ICoroutinePool
* Interface IPoolCoroutine
*
* @package PG\MSF\Coroutine
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Coroutine/MySql.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MySql extends Base
public $mysqlAsynPool;

/**
* @var mixed 绑定ID
* @var string|null 绑定ID
*/
public $bindId;

Expand Down
2 changes: 0 additions & 2 deletions src/Coroutine/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public function getController()

/**
* 请求的协程调度
*
* TODO: method too long to understand.
*/
public function run()
{
Expand Down
2 changes: 1 addition & 1 deletion src/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function onRequest($request, $response)

$instance->context = $instance->getObjectPool()->get(Context::class, [$this->requestId]);
// 初始化控制器
$instance->requestStartTime = (float)microtime(true);
$instance->requestStartTime = microtime(true);

// 构造请求上下文成员
$instance->context->setLogId($PGLog->logId);
Expand Down
15 changes: 0 additions & 15 deletions src/Route/IRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,4 @@ public function setRouteCache($path, $callable);
* @return mixed|null
*/
public function getRouteCache($path);


/**
* 获取请求报头的Host.
*
* @return string
*/
public function getHost();

/**
* 获取文件.
*
* @return mixed
*/
public function getFile();
}

0 comments on commit 36325af

Please sign in to comment.