Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] 连接中心一些改进 #687

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading