Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactored namespace, use elastic transport #232

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 10 additions & 10 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define('INDEX_NAME', 'test_elastic_index_name2');
class MyOpenSearchClass
{

protected ?\OpenSearch\Client $client;
protected ?OpenSearch\Client $client;
protected $existingID = 1668504743;
protected $deleteID = 1668504743;
protected $bulkIds = [];
Expand Down Expand Up @@ -369,7 +369,7 @@ This method allows you to set the hosts to use for the client. By default, the `

```php
<?php
$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
->setHosts(['https://localhost:9200'])
->build();
```
Expand All @@ -380,7 +380,7 @@ This method allows you to set the host selection mode to use for the client.

```php
<?php
$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
// Class needs to implement \OpenSearch\ConnectionPool\Selectors\SelectorInterface
->setSelector(new \OpenSearch\ConnectionPool\Selectors\RandomSelector())
->build();
Expand All @@ -391,7 +391,7 @@ This method allows you to set the host selection mode to use for the client.
This method allows you to set the basic authentication credentials to use for the client.

```php
$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
->setBasicAuthentication('username', 'password')
->build();
```
Expand All @@ -401,7 +401,7 @@ $client = (new \OpenSearch\ClientBuilder())
This method allows you to enable AWS SigV4 authentication for the client. The AWS SDK is required for this to work.

```php
$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
->setSigV4Region('us-east-2')

->setSigV4Service('es')
Expand All @@ -422,7 +422,7 @@ $client = (new \OpenSearch\ClientBuilder())
This method allows you to enable AWS SigV4 authentication for the client. The AWS SDK is required for this to work.

```php
$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
->setSigV4Region('us-east-2')

->setSigV4Service('aoss')
Expand All @@ -444,7 +444,7 @@ $client = (new \OpenSearch\ClientBuilder())
This method allows you to set custom curl options such as timeout/compression/etc.

```php
$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
->setConnectionParams([
'client' => [
'curl' => [
Expand All @@ -463,7 +463,7 @@ This method allows you to set a PSR-3 logger to use for the client. This will lo

```php
<?php
$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
->setLogger($monologLogger)
->build();
```
Expand All @@ -474,7 +474,7 @@ This method allows you to set the number of retries to use for the client.

```php

$client = (new \OpenSearch\ClientBuilder())
$client = (new OpenSearch\ClientBuilder())
->setRetries(3)
->build();
```
Expand All @@ -497,7 +497,7 @@ $config = [
'includePortInHostHeader' => true, // forces port from Hosts URL
];

$client = \OpenSearch\ClientBuilder::fromConfig($config);
$client = OpenSearch\ClientBuilder::fromConfig($config);

...
```
Expand Down
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"ext-json": ">=1.3.7",
"php": "^8.0",
"ext-curl": "*",
"ezimuel/ringphp": "^1.2.2",
"psr/log": "^1|^2|^3",
"symfony/yaml": "*"
"ext-json": ">=1.3.7",
"elastic/transport": "^v8.10",
"fig/http-message-util": "^1.1",
"psr/log": "^1|^2|^3"
},
"require-dev": {
"ext-zip": "*",
Expand All @@ -44,7 +44,7 @@
},
"autoload": {
"psr-4": {
"OpenSearch\\": "src/OpenSearch/"
"OpenSearch\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -54,7 +54,10 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": false
}
},
"scripts": {
"php-cs": [
Expand Down
12 changes: 6 additions & 6 deletions src/OpenSearch/Client.php → src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
use OpenSearch\Common\Exceptions\BadMethodCallException;
use OpenSearch\Common\Exceptions\NoNodesAvailableException;
use OpenSearch\Endpoints\AbstractEndpoint;
use OpenSearch\Namespaces\NamespaceBuilderInterface;
use OpenSearch\Namespaces\BooleanRequestWrapper;
use OpenSearch\Namespaces\AsyncSearchNamespace;
use OpenSearch\Namespaces\BooleanRequestWrapper;
use OpenSearch\Namespaces\CatNamespace;
use OpenSearch\Namespaces\ClusterNamespace;
use OpenSearch\Namespaces\DanglingIndicesNamespace;
Expand All @@ -36,15 +35,16 @@
use OpenSearch\Namespaces\KnnNamespace;
use OpenSearch\Namespaces\MlNamespace;
use OpenSearch\Namespaces\MonitoringNamespace;
use OpenSearch\Namespaces\NamespaceBuilderInterface;
use OpenSearch\Namespaces\NodesNamespace;
use OpenSearch\Namespaces\NotificationsNamespace;
use OpenSearch\Namespaces\ObservabilityNamespace;
use OpenSearch\Namespaces\PplNamespace;
use OpenSearch\Namespaces\QueryNamespace;
use OpenSearch\Namespaces\RemoteStoreNamespace;
use OpenSearch\Namespaces\RollupsNamespace;
use OpenSearch\Namespaces\SearchPipelineNamespace;
use OpenSearch\Namespaces\SearchableSnapshotsNamespace;
use OpenSearch\Namespaces\SearchPipelineNamespace;
use OpenSearch\Namespaces\SecurityNamespace;
use OpenSearch\Namespaces\SnapshotNamespace;
use OpenSearch\Namespaces\SqlNamespace;
Expand Down Expand Up @@ -1893,9 +1893,9 @@ public function request(string $method, string $uri, array $attributes = [])
$body = $attributes['body'] ?? null;
$options = $attributes['options'] ?? [];

$promise = $this->transport->performRequest($method, $uri, $params, $body, $options);
$promise = $this->transport->performRequest($method, $uri, $params, $body);

return $this->transport->resultOrFuture($promise, $options);
return $this->transport->resultOrFuture($promise);
}

/**
Expand All @@ -1911,6 +1911,6 @@ private function performRequest(AbstractEndpoint $endpoint)
$endpoint->getOptions()
);

return $this->transport->resultOrFuture($promise, $endpoint->getOptions());
return $this->transport->resultOrFuture($promise);
}
}
Loading