From 225eddaf6bfc00722912a906a0cce780a0b5e34e Mon Sep 17 00:00:00 2001 From: Kim Pepper Date: Wed, 20 Nov 2024 14:39:41 +1100 Subject: [PATCH] Address feedback Signed-off-by: Kim Pepper --- src/OpenSearch/Endpoints/AbstractEndpoint.php | 13 ++++++------ src/OpenSearch/LegacyTransportWrapper.php | 3 ++- .../Namespaces/AbstractNamespace.php | 2 -- src/OpenSearch/TransportFactory.php | 12 +++++------ util/template/client-class | 20 ------------------- 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/OpenSearch/Endpoints/AbstractEndpoint.php b/src/OpenSearch/Endpoints/AbstractEndpoint.php index 6718ee6f..bd4cc821 100644 --- a/src/OpenSearch/Endpoints/AbstractEndpoint.php +++ b/src/OpenSearch/Endpoints/AbstractEndpoint.php @@ -32,17 +32,17 @@ abstract class AbstractEndpoint implements EndpointInterface /** * @var array */ - protected array $params = []; + protected $params = []; /** * @var string|null */ - protected ?string $index = null; + protected $index = null; /** * @var string|int|null */ - protected string|int|null $id = null; + protected $id = null; /** * @var string|null @@ -52,17 +52,17 @@ abstract class AbstractEndpoint implements EndpointInterface /** * @var string|array|null */ - protected string|array|null $body = null; + protected $body = null; /** * @var array */ - private array $options = []; + private $options = []; /** * @var SerializerInterface */ - protected SerializerInterface $serializer; + protected $serializer; /** * @return string[] @@ -84,6 +84,7 @@ abstract public function getMethod(): string; * Set the parameters for this endpoint * * @param mixed[] $params Array of parameters + * @return $this */ public function setParams(array $params): static { diff --git a/src/OpenSearch/LegacyTransportWrapper.php b/src/OpenSearch/LegacyTransportWrapper.php index 2cadab6e..fd2cd7e5 100644 --- a/src/OpenSearch/LegacyTransportWrapper.php +++ b/src/OpenSearch/LegacyTransportWrapper.php @@ -28,7 +28,8 @@ public function sendRequest( array $headers = [], ): array|string|null { $promise = $this->transport->performRequest($method, $uri, $params, $body); - return $this->transport->resultOrFuture($promise); + $futureArray = $this->transport->resultOrFuture($promise); + return $futureArray->_value; } } diff --git a/src/OpenSearch/Namespaces/AbstractNamespace.php b/src/OpenSearch/Namespaces/AbstractNamespace.php index 1c2e6a55..38ea3e63 100644 --- a/src/OpenSearch/Namespaces/AbstractNamespace.php +++ b/src/OpenSearch/Namespaces/AbstractNamespace.php @@ -39,8 +39,6 @@ abstract class AbstractNamespace protected EndpointFactoryInterface $endpointFactory; - protected bool $isAsync = false; - /** * @var callable * diff --git a/src/OpenSearch/TransportFactory.php b/src/OpenSearch/TransportFactory.php index f488098f..40d66af7 100644 --- a/src/OpenSearch/TransportFactory.php +++ b/src/OpenSearch/TransportFactory.php @@ -16,17 +16,17 @@ */ class TransportFactory { - protected ?PsrRequestFactoryInterface $psrRequestFactory = null; + private ?PsrRequestFactoryInterface $psrRequestFactory = null; - protected ?StreamFactoryInterface $streamFactory = null; + private ?StreamFactoryInterface $streamFactory = null; - protected ?UriFactoryInterface $uriFactory = null; + private ?UriFactoryInterface $uriFactory = null; - protected ?SerializerInterface $serializer = null; + private ?SerializerInterface $serializer = null; - protected ?RequestFactoryInterface $requestFactory = null; + private ?RequestFactoryInterface $requestFactory = null; - protected ?ClientInterface $httpClient = null; + private ?ClientInterface $httpClient = null; protected function getHttpClient(): ?ClientInterface { diff --git a/util/template/client-class b/util/template/client-class index baea2e90..71119f0c 100644 --- a/util/template/client-class +++ b/util/template/client-class @@ -141,23 +141,6 @@ class Client } } - /** - * Check if the client is running in async mode. - */ - public function isAsync(): bool - { - return $this->isAsync; - } - - /** - * Set the client to run in async mode. - */ - public function setAsync(bool $isAsync): static - { - $this->isAsync = $isAsync; - return $this; - } - /** * Sends a raw request to the cluster * @return callable|array @@ -172,9 +155,6 @@ class Client return $this->httpTransport->sendRequest($method, $uri, $params, $body, $options['headers'] ?? []); } - /** - * @return callable|array - */ private function performRequest(AbstractEndpoint $endpoint): array|string|null { return $this->httpTransport->sendRequest(