From cdd7ad020e165fe680703b6d3319b908b682fb7a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 20 Oct 2023 17:12:29 +0300 Subject: jaeger-client -> opentelemetry --- vendor/php-http/guzzle7-adapter/src/Client.php | 75 ++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 vendor/php-http/guzzle7-adapter/src/Client.php (limited to 'vendor/php-http/guzzle7-adapter/src/Client.php') diff --git a/vendor/php-http/guzzle7-adapter/src/Client.php b/vendor/php-http/guzzle7-adapter/src/Client.php new file mode 100644 index 000000000..a92ab06bd --- /dev/null +++ b/vendor/php-http/guzzle7-adapter/src/Client.php @@ -0,0 +1,75 @@ + + */ +final class Client implements HttpClient, HttpAsyncClient +{ + /** + * @var ClientInterface + */ + private $guzzle; + + public function __construct(?ClientInterface $guzzle = null) + { + if (!$guzzle) { + $guzzle = self::buildClient(); + } + + $this->guzzle = $guzzle; + } + + /** + * Factory method to create the Guzzle 7 adapter with custom Guzzle configuration. + */ + public static function createWithConfig(array $config): Client + { + return new self(self::buildClient($config)); + } + + /** + * {@inheritdoc} + */ + public function sendRequest(RequestInterface $request): ResponseInterface + { + return $this->sendAsyncRequest($request)->wait(); + } + + /** + * {@inheritdoc} + */ + public function sendAsyncRequest(RequestInterface $request) + { + $promise = $this->guzzle->sendAsync($request); + + return new Promise($promise, $request); + } + + /** + * Build the Guzzle client instance. + */ + private static function buildClient(array $config = []): GuzzleClient + { + $handlerStack = new HandlerStack(Utils::chooseHandler()); + $handlerStack->push(Middleware::prepareBody(), 'prepare_body'); + $config = array_merge(['handler' => $handlerStack], $config); + + return new GuzzleClient($config); + } +} -- cgit v1.2.3