Skip to content

Commit

Permalink
Add Connection interface
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Nov 4, 2023
1 parent 07299ce commit 449b6ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
19 changes: 19 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Amp\Sql;

/**
* @template TResult of Result
* @template TStatement of Statement
* @template TTransaction of Transaction
* @template TConfig of SqlConfig
*
* @extends Link<TResult, TStatement, TTransaction>
*/
interface Connection extends Link
{
/**
* @return TConfig The configuration used to create this connection.
*/
public function getConfig(): SqlConfig;
}
5 changes: 3 additions & 2 deletions src/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @template TResult of Result
* @template TStatement of Statement
* @template TTransaction of Transaction
* @template TConfig of SqlConfig
*
* @extends Link<TResult, TStatement, TTransaction>
*/
Expand All @@ -15,9 +16,9 @@ interface Pool extends Link
* Gets a single connection from the pool to run a set of queries against a single connection.
* Generally a transaction should be used instead of this method.
*
* @return Link<TResult, TStatement, TTransaction>
* @return Connection<TResult, TStatement, TTransaction, TConfig>
*/
public function extractConnection(): Link;
public function extractConnection(): Connection;

/**
* @return int Total number of active connections in the pool.
Expand Down
6 changes: 3 additions & 3 deletions src/SqlConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* @template TConfig of SqlConfig
* @template TLink of Link
* @template TConnection of Connection
*/
interface SqlConnector
{
Expand All @@ -16,9 +16,9 @@ interface SqlConnector
*
* @param TConfig $config
*
* @return TLink
* @return TConnection
*
* @throws ConnectionException
*/
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): Link;
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): Connection;
}

0 comments on commit 449b6ed

Please sign in to comment.