From e2e3b27a5ff4faa88eb6bba4c44082d1db17649d Mon Sep 17 00:00:00 2001 From: Anton Komarev Date: Tue, 3 Sep 2024 19:07:53 +0300 Subject: [PATCH] Change method naming --- README.md | 2 +- src/OpenTsdbClient.php | 44 ++++++++++++------------- test/Integration/OpenTsdbClientTest.php | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 9c0cbec..c381de9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/OpenTsdbClient.php b/src/OpenTsdbClient.php index 156f2af..f01dab1 100644 --- a/src/OpenTsdbClient.php +++ b/src/OpenTsdbClient.php @@ -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 $dataPointList - */ - public function sendDataPointListSilently( - array $dataPointList, ): void { $result = $this->sendRequest( $this->buildUrl('/api/put'), @@ -128,6 +106,28 @@ public function sendDataPointListSilently( } } + /** + * @param list $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, diff --git a/test/Integration/OpenTsdbClientTest.php b/test/Integration/OpenTsdbClientTest.php index 3192250..fe661cd 100644 --- a/test/Integration/OpenTsdbClientTest.php +++ b/test/Integration/OpenTsdbClientTest.php @@ -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());