summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-10-20 17:12:29 +0300
committerAndrew Dolgov <[email protected]>2023-10-20 21:13:39 +0300
commitcdd7ad020e165fe680703b6d3319b908b682fb7a (patch)
treeb51eb09b7b4587e8fbc5624ac8d88d28cfcd0b04 /vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery
parent45a9ff0c88cbd33892ff16ab837e9059937d656e (diff)
jaeger-client -> opentelemetry
Diffstat (limited to 'vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery')
-rw-r--r--vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/DependencyResolver.php83
-rw-r--r--vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/HttpPlugClientResolver.php29
-rw-r--r--vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/MessageFactoryResolver.php88
-rw-r--r--vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/PsrClientResolver.php29
4 files changed, 229 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/DependencyResolver.php b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/DependencyResolver.php
new file mode 100644
index 000000000..8ba992f9a
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/DependencyResolver.php
@@ -0,0 +1,83 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Common\Adapter\HttpDiscovery;
+
+use Http\Client\HttpAsyncClient;
+use OpenTelemetry\SDK\Common\Http\DependencyResolverInterface;
+use OpenTelemetry\SDK\Common\Http\HttpPlug\Client\ResolverInterface as HttpPlugClientResolverInterface;
+use OpenTelemetry\SDK\Common\Http\Psr\Client\ResolverInterface as PsrClientResolverInterface;
+use OpenTelemetry\SDK\Common\Http\Psr\Message\FactoryResolverInterface as MessageFactoryResolverInterface;
+use Psr\Http\Client\ClientInterface;
+use Psr\Http\Message\RequestFactoryInterface;
+use Psr\Http\Message\ResponseFactoryInterface;
+use Psr\Http\Message\ServerRequestFactoryInterface;
+use Psr\Http\Message\StreamFactoryInterface;
+use Psr\Http\Message\UploadedFileFactoryInterface;
+use Psr\Http\Message\UriFactoryInterface;
+
+final class DependencyResolver implements DependencyResolverInterface
+{
+ private MessageFactoryResolverInterface $messageFactoryResolver;
+ private PsrClientResolverInterface $psrClientResolver;
+ private HttpPlugClientResolverInterface $httpPlugClientResolver;
+
+ public function __construct(
+ ?MessageFactoryResolverInterface $messageFactoryResolver = null,
+ ?PsrClientResolverInterface $psrClientResolver = null,
+ ?HttpPlugClientResolverInterface $httpPlugClientResolver = null
+ ) {
+ $this->messageFactoryResolver = $messageFactoryResolver ?? MessageFactoryResolver::create();
+ $this->psrClientResolver = $psrClientResolver ?? PsrClientResolver::create();
+ $this->httpPlugClientResolver = $httpPlugClientResolver ?? HttpPlugClientResolver::create();
+ }
+
+ public static function create(
+ ?MessageFactoryResolverInterface $messageFactoryResolver = null,
+ ?PsrClientResolverInterface $psrClientResolver = null,
+ ?HttpPlugClientResolverInterface $httpPlugClientResolver = null
+ ): self {
+ return new self($messageFactoryResolver, $psrClientResolver, $httpPlugClientResolver);
+ }
+
+ public function resolveRequestFactory(): RequestFactoryInterface
+ {
+ return $this->messageFactoryResolver->resolveRequestFactory();
+ }
+
+ public function resolveResponseFactory(): ResponseFactoryInterface
+ {
+ return $this->messageFactoryResolver->resolveResponseFactory();
+ }
+
+ public function resolveServerRequestFactory(): ServerRequestFactoryInterface
+ {
+ return $this->messageFactoryResolver->resolveServerRequestFactory();
+ }
+
+ public function resolveStreamFactory(): StreamFactoryInterface
+ {
+ return $this->messageFactoryResolver->resolveStreamFactory();
+ }
+
+ public function resolveUploadedFileFactory(): UploadedFileFactoryInterface
+ {
+ return $this->messageFactoryResolver->resolveUploadedFileFactory();
+ }
+
+ public function resolveUriFactory(): UriFactoryInterface
+ {
+ return $this->messageFactoryResolver->resolveUriFactory();
+ }
+
+ public function resolveHttpPlugAsyncClient(): HttpAsyncClient
+ {
+ return $this->httpPlugClientResolver->resolveHttpPlugAsyncClient();
+ }
+
+ public function resolvePsrClient(): ClientInterface
+ {
+ return $this->psrClientResolver->resolvePsrClient();
+ }
+}
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();
+ }
+}
diff --git a/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/MessageFactoryResolver.php b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/MessageFactoryResolver.php
new file mode 100644
index 000000000..6ed0895ff
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/MessageFactoryResolver.php
@@ -0,0 +1,88 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Common\Adapter\HttpDiscovery;
+
+use Http\Discovery\Psr17FactoryDiscovery;
+use OpenTelemetry\SDK\Common\Http\Psr\Message\FactoryResolverInterface;
+use Psr\Http\Message\RequestFactoryInterface;
+use Psr\Http\Message\ResponseFactoryInterface;
+use Psr\Http\Message\ServerRequestFactoryInterface;
+use Psr\Http\Message\StreamFactoryInterface;
+use Psr\Http\Message\UploadedFileFactoryInterface;
+use Psr\Http\Message\UriFactoryInterface;
+
+final class MessageFactoryResolver implements FactoryResolverInterface
+{
+ private ?RequestFactoryInterface $requestFactory;
+ private ?ResponseFactoryInterface $responseFactory;
+ private ?ServerRequestFactoryInterface $serverRequestFactory;
+ private ?StreamFactoryInterface $streamFactory;
+ private ?UploadedFileFactoryInterface $uploadedFileFactory;
+ private ?UriFactoryInterface $uriFactory;
+
+ public function __construct(
+ ?RequestFactoryInterface $requestFactory = null,
+ ?ResponseFactoryInterface $responseFactory = null,
+ ?ServerRequestFactoryInterface $serverRequestFactory = null,
+ ?StreamFactoryInterface $streamFactory = null,
+ ?UploadedFileFactoryInterface $uploadedFileFactory = null,
+ ?UriFactoryInterface $uriFactory = null
+ ) {
+ $this->requestFactory = $requestFactory;
+ $this->responseFactory = $responseFactory;
+ $this->serverRequestFactory = $serverRequestFactory;
+ $this->streamFactory = $streamFactory;
+ $this->uploadedFileFactory = $uploadedFileFactory;
+ $this->uriFactory = $uriFactory;
+ }
+
+ public static function create(
+ ?RequestFactoryInterface $requestFactory = null,
+ ?ResponseFactoryInterface $responseFactory = null,
+ ?ServerRequestFactoryInterface $serverRequestFactory = null,
+ ?StreamFactoryInterface $streamFactory = null,
+ ?UploadedFileFactoryInterface $uploadedFileFactory = null,
+ ?UriFactoryInterface $uriFactory = null
+ ): self {
+ return new self(
+ $requestFactory,
+ $responseFactory,
+ $serverRequestFactory,
+ $streamFactory,
+ $uploadedFileFactory,
+ $uriFactory
+ );
+ }
+
+ public function resolveRequestFactory(): RequestFactoryInterface
+ {
+ return $this->requestFactory ??= Psr17FactoryDiscovery::findRequestFactory();
+ }
+
+ public function resolveResponseFactory(): ResponseFactoryInterface
+ {
+ return $this->responseFactory ??= Psr17FactoryDiscovery::findResponseFactory();
+ }
+
+ public function resolveServerRequestFactory(): ServerRequestFactoryInterface
+ {
+ return $this->serverRequestFactory ??= Psr17FactoryDiscovery::findServerRequestFactory();
+ }
+
+ public function resolveStreamFactory(): StreamFactoryInterface
+ {
+ return $this->streamFactory ??= Psr17FactoryDiscovery::findStreamFactory();
+ }
+
+ public function resolveUploadedFileFactory(): UploadedFileFactoryInterface
+ {
+ return $this->uploadedFileFactory ??= Psr17FactoryDiscovery::findUploadedFileFactory();
+ }
+
+ public function resolveUriFactory(): UriFactoryInterface
+ {
+ return $this->uriFactory ??= Psr17FactoryDiscovery::findUriFactory();
+ }
+}
diff --git a/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/PsrClientResolver.php b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/PsrClientResolver.php
new file mode 100644
index 000000000..46fb36312
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Common/Adapter/HttpDiscovery/PsrClientResolver.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Common\Adapter\HttpDiscovery;
+
+use Http\Discovery\Psr18ClientDiscovery;
+use OpenTelemetry\SDK\Common\Http\Psr\Client\ResolverInterface;
+use Psr\Http\Client\ClientInterface;
+
+final class PsrClientResolver implements ResolverInterface
+{
+ private ?ClientInterface $client;
+
+ public function __construct(?ClientInterface $client = null)
+ {
+ $this->client = $client;
+ }
+
+ public static function create(?ClientInterface $client = null): self
+ {
+ return new self($client);
+ }
+
+ public function resolvePsrClient(): ClientInterface
+ {
+ return $this->client ??= Psr18ClientDiscovery::find();
+ }
+}