diff options
Diffstat (limited to 'vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/HttpPlugClientResolver.php')
-rw-r--r-- | vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/HttpPlugClientResolver.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/HttpPlugClientResolver.php b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/HttpPlugClientResolver.php new file mode 100644 index 000000000..9751984ee --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/HttpPlugClientResolver.php @@ -0,0 +1,29 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Adapter\HttpDiscovery; + +use Http\Client\HttpAsyncClient; +use Http\Discovery\HttpAsyncClientDiscovery; +use OpenTelemetry\SDK\Common\Http\HttpPlug\Client\ResolverInterface; + +final class HttpPlugClientResolver implements ResolverInterface +{ + private ?HttpAsyncClient $httpAsyncClient; + + public function __construct(?HttpAsyncClient $httpAsyncClient = null) + { + $this->httpAsyncClient = $httpAsyncClient; + } + + public static function create(?HttpAsyncClient $httpAsyncClient = null): self + { + return new self($httpAsyncClient); + } + + public function resolveHttpPlugAsyncClient(): HttpAsyncClient + { + return $this->httpAsyncClient ??= HttpAsyncClientDiscovery::find(); + } +} |