This commit is contained in:
zyimm 2021-09-23 15:13:55 +08:00
parent a8310d9d25
commit b017b7ee89
3 changed files with 8 additions and 2 deletions

View File

@ -9,9 +9,11 @@
], ],
"require": { "require": {
"php": ">=7.2", "php": ">=7.2",
"hyperf/framework": "~2.1.0",
"psr/container": "^1.0", "psr/container": "^1.0",
"hyperf/pool": "^2.0", "hyperf/pool": "^2.0",
"hyperf/utils": "^2.0.0", "hyperf/utils": "^2.0.0",
"hyperf/di": "^2.0.0",
"ext-mongodb": "*" "ext-mongodb": "*"
}, },
"require-dev": { "require-dev": {

View File

@ -4,6 +4,7 @@
namespace Hyperf\Mongodb\Pool; namespace Hyperf\Mongodb\Pool;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Di\Exception\NotFoundException;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Swoole\Coroutine\Channel; use Swoole\Coroutine\Channel;
@ -24,7 +25,10 @@ class PoolFactory
$this->container = $container; $this->container = $container;
} }
public function getPool(string $name): MongoDBPool /**
* @throws NotFoundException
*/
public function getPool(string $name): Channel
{ {
if (isset($this->pools[$name])) { if (isset($this->pools[$name])) {
return $this->pools[$name]; return $this->pools[$name];

View File

@ -4,7 +4,7 @@ namespace Zyimm\Test;
class MongoTest extends \PHPUnit\Framework\TestCase class MongoTest extends \PHPUnit\Framework\TestCase
{ {
public function testfindALL() public function testFindALL()
{ {
$this->assertArrayHasKey('error_code', Sdk::instance($this->config()) $this->assertArrayHasKey('error_code', Sdk::instance($this->config())
->service() ->service()