From c52377aad1431aceb8868ccdc6bb82acb3774bbc Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 12:04:04 +0200 Subject: [PATCH 1/5] Allows non write adapters * Renamed `AdapterInterface` to `WritableInterface` * Constructor now allows different adapter implementations * Check that adapter implements `WritableInterface` during data send --- src/Adapter/AdapterAbstract.php | 9 ++------- src/Adapter/AdapterInterface.php | 15 --------------- src/Adapter/WritableInterface.php | 7 +++++++ src/Client.php | 7 ++++++- 4 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 src/Adapter/AdapterInterface.php create mode 100644 src/Adapter/WritableInterface.php diff --git a/src/Adapter/AdapterAbstract.php b/src/Adapter/AdapterAbstract.php index b03d47681..342b40bda 100644 --- a/src/Adapter/AdapterAbstract.php +++ b/src/Adapter/AdapterAbstract.php @@ -2,22 +2,17 @@ namespace InfluxDB\Adapter; use InfluxDB\Options; +use InfluxDB\Adapter\WritableInterface; -abstract class AdapterAbstract implements AdapterInterface +abstract class AdapterAbstract implements WritableInterface { private $options; - /** - * @param Options $options - */ public function __construct(Options $options) { $this->options = $options; } - /** - * @return Options - */ public function getOptions() { return $this->options; diff --git a/src/Adapter/AdapterInterface.php b/src/Adapter/AdapterInterface.php deleted file mode 100644 index 23bdf7a68..000000000 --- a/src/Adapter/AdapterInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -adapter = $adapter; return $this; @@ -24,6 +25,10 @@ class Client public function mark($name, array $values = []) { + if (!($this->getAdapter() instanceOf WritableInterface)) { + throw new \BadMethodCallException("You can write data to database only if the adapter supports it!"); + } + $data = $name; if (!is_array($name)) { $data =[]; From 452b50fd30de0937e87954418ddbd54773311bce Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 12:08:40 +0200 Subject: [PATCH 2/5] Removed useless `return $this` during constructor --- src/Client.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index e1537ee84..fa795a22c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -14,7 +14,6 @@ class Client public function __construct(Adapter\AdapterInterface $adapter) { $this->adapter = $adapter; - return $this; } public function getAdapter() From dd255ad2717a5eab626f7a5e265e223923d2a674 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 12:11:50 +0200 Subject: [PATCH 3/5] Removed deprecated from GuzzleAdapter --- src/Adapter/GuzzleAdapter.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php index 2f5509bd9..d55352101 100644 --- a/src/Adapter/GuzzleAdapter.php +++ b/src/Adapter/GuzzleAdapter.php @@ -4,12 +4,6 @@ namespace InfluxDB\Adapter; use GuzzleHttp\Client; use InfluxDB\Options; -/** - * Class GuzzleAdapter - * @package InfluxDB\Adapter - * - * @deprecated - */ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface { private $httpClient; From 18442a6dd6057963590a5b1e842858c746a74d85 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 12:20:14 +0200 Subject: [PATCH 4/5] Fixes benchmark procedures --- README.md | 10 +++++----- benchmarks/Benchmarks/InfluxDB/AdapterEvent.php | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4a35a12e1..2d5171146 100644 --- a/README.md +++ b/README.md @@ -268,8 +268,8 @@ The impact using UDP/IP or HTTP adapters Corley\Benchmarks\InfluxDB\AdapterEvent Method Name Iterations Average Time Ops/second ------------------------ ------------ -------------- ------------- - sendDataUsingHttpAdapter: [1,000 ] [0.0162619416714] [61.49327] - sendDataUsingUdpAdapter : [1,000 ] [0.0000890662670] [11,227.59529] + sendDataUsingHttpAdapter: [1,000 ] [0.0167509446144] [59.69813] + sendDataUsingUdpAdapter : [1,000 ] [0.0000905156136] [11,047.81773] ``` ### Message to inline protocol conversion @@ -283,8 +283,8 @@ The impact of message to inline protocol conversion is: Corley\Benchmarks\InfluxDB\MessageToInlineProtocolEvent Method Name Iterations Average Time Ops/second ---------------------------------------------------- ------------ -------------- ------------- - convertMessageToInlineProtocolWithNoTags : [10,000 ] [0.0000230122805] [43,455.05877] - convertMessageToInlineProtocolWithGlobalTags : [10,000 ] [0.0000301691532] [33,146.43911] - convertMessageToInlineProtocolWithDifferentTagLevels: [10,000 ] [0.0000327563763] [30,528.40741] + convertMessageToInlineProtocolWithNoTags : [10,000 ] [0.0000237422466] [42,119.01324] + convertMessageToInlineProtocolWithGlobalTags : [10,000 ] [0.0000306700468] [32,605.10185] + convertMessageToInlineProtocolWithDifferentTagLevels: [10,000 ] [0.0000343942404] [29,074.63543] ``` diff --git a/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php b/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php index ba43adac0..e52604941 100644 --- a/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php +++ b/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php @@ -15,23 +15,21 @@ class AdapterEvent extends AthleticEvent public function setUp() { - $client = new Client(); $options = new Options(); $options->setHost("localhost"); $options->setPort(8086); $options->setUsername("root"); $options->setPassword("root"); $options->setDatabase("tcp.test"); - $client->setAdapter( - new GuzzleAdapter(new HttpClient(), $options) - ); + + $client = new Client(new GuzzleAdapter(new HttpClient(), $options)); + $this->httpClient = $client; $opts = new Options(); $opts->setPort(4444); - $client = new Client(); - $client->setAdapter(new UdpAdapter($opts)); + $client = new Client(new UdpAdapter($opts)); $this->udpClient = $client; } From 5d48787dc3167c98124d43f4902c93e27b422a73 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 12:22:46 +0200 Subject: [PATCH 5/5] Bumped version 0.4.4 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 17b2ccd9b..6f2743d65 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.3 +0.4.4