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: add a ping() API to check status of OSS and Cloud instance #97

Merged
merged 3 commits into from
Oct 18, 2021
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 2.3.0 [unreleased]

### Features
1. [#97](https://github.com/influxdata/influxdb-client-php/pull/97): Add `ping()` to check status of OSS and Cloud instance

### Bug Fixes
1. [#95](https://github.com/influxdata/influxdb-client-php/pull/95): Fix file descriptor leaks in WriteApi
1. [#96](https://github.com/influxdata/influxdb-client-php/pull/96): Fix nanosecond datetime string convertor
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ $this->writeApi->write($point);

### Check the server status

Server availability can be checked using the `$client->health();` method. That is equivalent of the [influx ping](https://v2.docs.influxdata.com/v2.0/reference/cli/influx/ping/).
Server availability can be checked using the `$client->ping();` method. That is equivalent of the [influx ping](https://v2.docs.influxdata.com/v2.0/reference/cli/influx/ping/).

### InfluxDB 1.8 API compatibility

Expand Down
14 changes: 14 additions & 0 deletions src/InfluxDB2/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace InfluxDB2;

use InfluxDB2\Model\HealthCheck;
use InfluxDB2\Service\PingService;
use ReflectionClass;
use RuntimeException;

Expand Down Expand Up @@ -101,13 +102,26 @@ public function createQueryApi(): QueryApi
/**
* Get the health of an instance.
*
* @deprecated Use `ping()` instead
* @return HealthCheck
*/
public function health(): HealthCheck
{
return (new HealthApi($this->options))->health();
}

/**
* Checks the status of InfluxDB instance and version of InfluxDB.
*
* @return array with response headers: 'X-Influxdb-Build', 'X-Influxdb-Version'
*/
public function ping(): array
{
$service = $this->createService(PingService::class);
$pingWithHttpInfo = $service->getPingWithHttpInfo();
return $pingWithHttpInfo[2];
}

/**
* Close all connections into InfluxDB
*/
Expand Down
Loading