Skip to content

Commit

Permalink
修改连接池配置的timeout字段为float (swoft-cloud/swoft-component#177)
Browse files Browse the repository at this point in the history
* 更改连接池timeout字段为float

* 增加单测
  • Loading branch information
limingxinleo authored and huangzhhui committed Aug 12, 2018
1 parent cc6632d commit 3c7b226
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Pool/PoolConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function getMaxActive(): int;
public function getMaxWait(): int;

/**
* @return int
* @return float
*/
public function getTimeout(): int;
public function getTimeout(): float;

/**
* @return array
Expand Down
6 changes: 3 additions & 3 deletions src/Pool/PoolProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PoolProperties implements PoolConfigInterface
/**
* Connection timeout
*
* @var int
* @var float
*/
protected $timeout = 3;

Expand Down Expand Up @@ -126,9 +126,9 @@ public function getMaxWait(): int
}

/**
* @return int
* @return float
*/
public function getTimeout(): int
public function getTimeout(): float
{
return $this->timeout;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Cases/Pool/DemoPoolConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
*/
class DemoPoolConfig extends PoolProperties
{

protected $timeout = 0.5;
}
10 changes: 10 additions & 0 deletions test/Cases/PoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SwoftTest\Pool\ConsulEnvConfig;
use SwoftTest\Pool\ConsulPptConfig;
use SwoftTest\Pool\DemoPool;
use SwoftTest\Pool\DemoPoolConfig;
use SwoftTest\Pool\EnvAndPptFromPptPoolConfig;
use SwoftTest\Pool\EnvAndPptPoolConfig;
use SwoftTest\Pool\EnvPoolConfig;
Expand Down Expand Up @@ -170,4 +171,13 @@ public function testGetConnectionByCo()
$this->testGetConnection();
});
}

public function testPoolConfigTimeout()
{
$pConfig = App::getBean(EnvPoolConfig::class);
$this->assertEquals($pConfig->getTimeout(), 2);

$dConfig = App::getBean(DemoPoolConfig::class);
$this->assertEquals($dConfig->getTimeout(), 0.5);
}
}

0 comments on commit 3c7b226

Please sign in to comment.