Skip to content

Commit

Permalink
新增控制器等待时间
Browse files Browse the repository at this point in the history
  • Loading branch information
yf committed Nov 19, 2018
1 parent e6d1759 commit f9e26df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ private function registerDefaultCallBack(\swoole_server $server,string $serverTy
if($max == 0){
$max = 15;
}

$waitTime = intval(Di::getInstance()->get(SysConst::HTTP_CONTROLLER_POOL_WAIT_TIME));
if($waitTime == 0){
$waitTime = 5;
}
$dispatcher = new Dispatcher($namespace,$depth,$max);
$dispatcher->setControllerPoolWaitTime($waitTime);
$httpExceptionHandler = Di::getInstance()->get(SysConst::HTTP_EXCEPTION_HANDLER);
if(!is_callable($httpExceptionHandler)){
$httpExceptionHandler = function ($throwable,$request,$response){
Expand Down
1 change: 1 addition & 0 deletions src/SysConst.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ class SysConst
const HTTP_CONTROLLER_MAX_DEPTH = 'CONTROLLER_MAX_DEPTH';
const HTTP_EXCEPTION_HANDLER = 'HTTP_EXCEPTION_HANDLER';
const HTTP_CONTROLLER_POOL_MAX_NUM = 'HTTP_CONTROLLER_POOL_MAX_NUM';
const HTTP_CONTROLLER_POOL_WAIT_TIME = 'HTTP_CONTROLLER_POOL_WAIT_TIME';

}

0 comments on commit f9e26df

Please sign in to comment.