diff --git a/composer.json b/composer.json index eaf16a9..9d83f48 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "minimum-stability": "stable", "require": { "php": ">=8.4", + "psr/http-client": "^1.0", "utopia-php/client": "^0.1|^0.2", "utopia-php/database": "5.*|6.0.*", "utopia-php/query": "0.1.*" diff --git a/composer.lock b/composer.lock index 608f1dc..c7dac0b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5b3770da8c02f718d34e73b85e3ad64a", + "content-hash": "15b52e21547085e954eef3a3c399ff68", "packages": [ { "name": "brick/math", diff --git a/src/Usage/Adapter/ClickHouse.php b/src/Usage/Adapter/ClickHouse.php index 2a8826e..698915a 100644 --- a/src/Usage/Adapter/ClickHouse.php +++ b/src/Usage/Adapter/ClickHouse.php @@ -5,6 +5,7 @@ use DateTime; use DateTimeZone; use Exception; +use Psr\Http\Client\ClientInterface; use Throwable; use Utopia\Client; use Utopia\Client\Adapter\Curl\Client as CurlAdapter; @@ -93,7 +94,7 @@ class ClickHouse extends SQL /** @var bool Whether to use HTTPS for ClickHouse HTTP interface */ private bool $secure = false; - private Client $client; + private ClientInterface $client; private RequestFactory $requestFactory; @@ -148,9 +149,11 @@ class ClickHouse extends SQL * @param string $password ClickHouse password (default: '') * @param int $port ClickHouse HTTP port (default: 8123) * @param bool $secure Whether to use HTTPS (default: false) - * @param Client|null $client HTTP transport. Defaults to a cURL client - * with persistent connection reuse. Inject your own to control timeouts, - * TLS, or retries — e.g. wrap an adapter in `Utopia\Client\Decorator\Retry`. + * @param ClientInterface|null $client PSR-18 HTTP transport. Defaults to a + * cURL client with persistent connection reuse. Inject your own to control + * timeouts, TLS, or retries — e.g. wrap an adapter in + * `Utopia\Client\Decorator\Retry`, or pass a `Utopia\Client\Pool` to share a + * bounded set of connections across concurrent (coroutine) callers. */ public function __construct( string $host, @@ -158,7 +161,7 @@ public function __construct( string $password = '', int $port = self::DEFAULT_PORT, bool $secure = false, - ?Client $client = null + ?ClientInterface $client = null ) { $this->validateHost($host); $this->validatePort($port);