diff --git a/src/Components/connection-center/src/ConnectionCenter.php b/src/Components/connection-center/src/ConnectionCenter.php index 10b51b1004..d44a39ce72 100644 --- a/src/Components/connection-center/src/ConnectionCenter.php +++ b/src/Components/connection-center/src/ConnectionCenter.php @@ -98,7 +98,7 @@ public function getRequestContextConnection(string $name): IConnection } } } - if (null === $connection) + if (null === $connection || ConnectionStatus::Available !== $connection->getStatus()) { $connection = $this->getConnection($name); $requestContext[static::class][$name] = [ diff --git a/src/Components/connection-center/src/Contract/IConnection.php b/src/Components/connection-center/src/Contract/IConnection.php index 775e86d699..3b63fcee6c 100644 --- a/src/Components/connection-center/src/Contract/IConnection.php +++ b/src/Components/connection-center/src/Contract/IConnection.php @@ -9,8 +9,14 @@ */ use Imi\ConnectionCenter\Enum\ConnectionStatus; +/** + * @template T of object + */ interface IConnection { + /** + * @param T $instance + */ public function __construct(IConnectionManager $manager, object $instance); /** @@ -20,6 +26,8 @@ public function getManager(): IConnectionManager; /** * 获取连接资源管理的对象实例. + * + * @return T */ public function getInstance(): object;