Skip to content

Commit

Permalink
Change method naming
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev committed Sep 3, 2024
1 parent 3bdc028 commit e2e3b27
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This package does not cover Telnet API, and that's why:
- HTTP API use cases: production applications, complex data queries, integrations with other systems, and secure communications.

OpenTSDB HTTP API supported by:
- [VictoriaMetrics](https://docs.victoriametrics.com/#sending-opentsdb-data-via-http-apiput-requests) but because of [limitation](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/959) `sendDataPointListSilently` should be used to send metrics.
- [VictoriaMetrics](https://docs.victoriametrics.com/#sending-opentsdb-data-via-http-apiput-requests) but because of [limitation](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/959) `sendDataPointListWithDebug` method is not supported.

## What is OpenTSDB

Expand Down
44 changes: 22 additions & 22 deletions src/OpenTsdbClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,6 @@ public function __construct(
*/
public function sendDataPointList(
array $dataPointList,
): SendDataPointListResponse {
$result = $this->sendRequest(
$this->buildUrl('/api/put?details&summary'),
json_encode($dataPointList),
);

$statusCode = $result->getStatusCode();
$decodedResult = json_decode($result->getBody()->getContents(), true);

return new SendDataPointListResponse(
$statusCode,
$decodedResult['success'],
$decodedResult['failed'],
$decodedResult['errors'],
);
}

/**
* @param list<DataPoint> $dataPointList
*/
public function sendDataPointListSilently(
array $dataPointList,
): void {
$result = $this->sendRequest(
$this->buildUrl('/api/put'),
Expand Down Expand Up @@ -128,6 +106,28 @@ public function sendDataPointListSilently(
}
}

/**
* @param list<DataPoint> $dataPointList
*/
public function sendDataPointListWithDebug(
array $dataPointList,
): SendDataPointListResponse {
$result = $this->sendRequest(
$this->buildUrl('/api/put?details&summary'),
json_encode($dataPointList),
);

$statusCode = $result->getStatusCode();
$decodedResult = json_decode($result->getBody()->getContents(), true);

return new SendDataPointListResponse(
$statusCode,
$decodedResult['success'],
$decodedResult['failed'],
$decodedResult['errors'],
);
}

private function sendRequest(
string $url,
string $body,
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/OpenTsdbClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testSuccess(): void

$openTsdbClient = $this->initOpenTsdbClient();

$response = $openTsdbClient->sendDataPointList($dataPointList);
$response = $openTsdbClient->sendDataPointListWithDebug($dataPointList);
$this->assertSame(200, $response->httpStatusCode());
$this->assertSame(2, $response->success());
$this->assertSame(0, $response->failed());
Expand Down

0 comments on commit e2e3b27

Please sign in to comment.