Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Health | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| _retrieveHealthData | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Elastica; |
| 4 | |
| 5 | use Elastica\Client; |
| 6 | |
| 7 | /** |
| 8 | * Overrides Elastica's Health class to allow filtering by index. |
| 9 | */ |
| 10 | class Health extends \Elastica\Cluster\Health { |
| 11 | |
| 12 | /** @var string|null Index or index pattern to limit health check to. */ |
| 13 | private $index; |
| 14 | |
| 15 | /** |
| 16 | * @param Client $client |
| 17 | * @param string|null $index Index or index pattern to limit health check to. |
| 18 | */ |
| 19 | public function __construct( Client $client, ?string $index = null ) { |
| 20 | $this->index = $index; |
| 21 | parent::__construct( $client ); |
| 22 | } |
| 23 | |
| 24 | /** @inheritDoc */ |
| 25 | protected function _retrieveHealthData(): array { |
| 26 | $endpoint = new \Elasticsearch\Endpoints\Cluster\Health(); |
| 27 | if ( $this->index ) { |
| 28 | $endpoint->setIndex( $this->index ); |
| 29 | } |
| 30 | $endpoint->setParams( [ 'level' => 'shards' ] ); |
| 31 | $response = $this->_client->requestEndpoint( $endpoint ); |
| 32 | return $response->getData(); |
| 33 | } |
| 34 | |
| 35 | } |