From 0bcd9bc4d902ccdc5e2661b274e1ca64906df38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Mon, 13 Aug 2018 00:24:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=9E=E6=8E=A5=E6=B1=A0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=9A=84timeout=E5=AD=97=E6=AE=B5=E4=B8=BAfl?= =?UTF-8?q?oat=20(https://github.com/swoft-cloud/swoft-component/pull/177)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 更改连接池timeout字段为float * 增加单测 --- src/Pool/PoolConfigInterface.php | 4 ++-- src/Pool/PoolProperties.php | 6 +++--- test/Cases/Pool/DemoPoolConfig.php | 2 +- test/Cases/PoolTest.php | 10 ++++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Pool/PoolConfigInterface.php b/src/Pool/PoolConfigInterface.php index 854b8310..85d03801 100644 --- a/src/Pool/PoolConfigInterface.php +++ b/src/Pool/PoolConfigInterface.php @@ -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 diff --git a/src/Pool/PoolProperties.php b/src/Pool/PoolProperties.php index 13393743..957f0bad 100644 --- a/src/Pool/PoolProperties.php +++ b/src/Pool/PoolProperties.php @@ -53,7 +53,7 @@ class PoolProperties implements PoolConfigInterface /** * Connection timeout * - * @var int + * @var float */ protected $timeout = 3; @@ -126,9 +126,9 @@ public function getMaxWait(): int } /** - * @return int + * @return float */ - public function getTimeout(): int + public function getTimeout(): float { return $this->timeout; } diff --git a/test/Cases/Pool/DemoPoolConfig.php b/test/Cases/Pool/DemoPoolConfig.php index 62ba6253..ec564f54 100644 --- a/test/Cases/Pool/DemoPoolConfig.php +++ b/test/Cases/Pool/DemoPoolConfig.php @@ -12,5 +12,5 @@ */ class DemoPoolConfig extends PoolProperties { - + protected $timeout = 0.5; } \ No newline at end of file diff --git a/test/Cases/PoolTest.php b/test/Cases/PoolTest.php index 91de622b..047a28e0 100644 --- a/test/Cases/PoolTest.php +++ b/test/Cases/PoolTest.php @@ -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; @@ -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); + } }