Skip to content

Commit

Permalink
Update: 改进连接中心 (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX authored Apr 4, 2024
1 parent e64ea5d commit 26657dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Components/connection-center/src/ConnectionCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down
8 changes: 8 additions & 0 deletions src/Components/connection-center/src/Contract/IConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand All @@ -20,6 +26,8 @@ public function getManager(): IConnectionManager;

/**
* 获取连接资源管理的对象实例.
*
* @return T
*/
public function getInstance(): object;

Expand Down

0 comments on commit 26657dd

Please sign in to comment.