From b9248c1e02343456610a14431fa0ed48e51b9cb5 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Wed, 10 Sep 2014 12:00:46 +0200 Subject: [PATCH 001/158] Skeleton --- .gitignore | 1 + composer.json | 26 ++ composer.lock | 447 ++++++++++++++++++++++ spec/InfluxDB/Adapter/UdpSpec.php | 24 ++ spec/InfluxDB/ClientSpec.php | 39 ++ src/InfluxDB/Adapter/AdapterInterface.php | 13 + src/InfluxDB/Adapter/Udp.php | 52 +++ src/InfluxDB/Client.php | 39 ++ src/InfluxDB/ClientInterface.php | 11 + 9 files changed, 652 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 spec/InfluxDB/Adapter/UdpSpec.php create mode 100644 spec/InfluxDB/ClientSpec.php create mode 100644 src/InfluxDB/Adapter/AdapterInterface.php create mode 100644 src/InfluxDB/Adapter/Udp.php create mode 100644 src/InfluxDB/Client.php create mode 100644 src/InfluxDB/ClientInterface.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..22d0d82f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor diff --git a/composer.json b/composer.json new file mode 100644 index 000000000..13851b357 --- /dev/null +++ b/composer.json @@ -0,0 +1,26 @@ +{ + "name": "corley/influxdb-sdk", + "description": "InfluxDb PHP sdk for send messages", + "require-dev": { + "phpspec/phpspec": "2.*" + }, + "authors": [ + { + "name": "Gianluca Arbezzano", + "email": "gianluca.arbezzano@corley.it" + }, + { + "name": "Walter Dal Mut", + "email": "walter.dalmut@corley.it" + }, + { + "name": "Gabriele Mittica", + "email": "gabriele.mittica@corley.it" + } + ], + "autoload": { + "psr-0": { + "InfluxDB": "./src/" + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 000000000..4abb61a3f --- /dev/null +++ b/composer.lock @@ -0,0 +1,447 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "ebef29b39aea3cab015d3bf51e00121e", + "packages": [ + + ], + "packages-dev": [ + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "38743b677965c48a637097b2746a281264ae2347" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/38743b677965c48a637097b2746a281264ae2347", + "reference": "38743b677965c48a637097b2746a281264ae2347", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*@stable" + }, + "suggest": { + "dflydev/markdown": "1.0.*", + "erusev/parsedown": "~0.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2014-08-09 10:27:07" + }, + { + "name": "phpspec/php-diff", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpspec/php-diff.git", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a", + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Diff": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Chris Boulton", + "homepage": "http://github.com/chrisboulton", + "role": "Original developer" + } + ], + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", + "time": "2013-11-01 13:02:21" + }, + { + "name": "phpspec/phpspec", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/phpspec.git", + "reference": "61712147412cb647b6cb68b19833a60bfda759a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/phpspec/zipball/61712147412cb647b6cb68b19833a60bfda759a1", + "reference": "61712147412cb647b6cb68b19833a60bfda759a1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpspec/php-diff": "~1.0.0", + "phpspec/prophecy": "~1.1", + "symfony/console": "~2.1", + "symfony/event-dispatcher": "~2.1", + "symfony/finder": "~2.1", + "symfony/yaml": "~2.1" + }, + "require-dev": { + "behat/behat": "~2.5", + "bossa/phpspec2-expect": "dev-master", + "symfony/filesystem": "~2.1" + }, + "suggest": { + "phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters" + }, + "bin": [ + "bin/phpspec" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "PhpSpec": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "homepage": "http://marcelloduarte.net/" + } + ], + "description": "Specification-oriented BDD framework for PHP 5.3+", + "homepage": "http://phpspec.net/", + "keywords": [ + "BDD", + "SpecBDD", + "TDD", + "spec", + "specification", + "testing", + "tests" + ], + "time": "2014-07-01 14:09:19" + }, + { + "name": "phpspec/prophecy", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "328484c88ed3cd7d1980b624bb98fa635f212ec9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/328484c88ed3cd7d1980b624bb98fa635f212ec9", + "reference": "328484c88ed3cd7d1980b624bb98fa635f212ec9", + "shasum": "" + }, + "require": { + "phpdocumentor/reflection-docblock": "~2.0" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "http://phpspec.org", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2014-07-18 21:26:55" + }, + { + "name": "symfony/console", + "version": "v2.5.4", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "748beed2a1e73179c3f5154d33fe6ae100c1aeb1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/748beed2a1e73179c3f5154d33fe6ae100c1aeb1", + "reference": "748beed2a1e73179c3f5154d33fe6ae100c1aeb1", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Console Component", + "homepage": "http://symfony.com", + "time": "2014-08-14 16:10:54" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.5.4", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", + "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0", + "symfony/dependency-injection": "~2.0", + "symfony/stopwatch": "~2.2" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2014-07-28 13:20:46" + }, + { + "name": "symfony/finder", + "version": "v2.5.4", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder.git", + "reference": "f40854d1a19c339c7f969f8f6d6d6e9153311c4c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Finder/zipball/f40854d1a19c339c7f969f8f6d6d6e9153311c4c", + "reference": "f40854d1a19c339c7f969f8f6d6d6e9153311c4c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Finder\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Finder Component", + "homepage": "http://symfony.com", + "time": "2014-09-03 09:00:14" + }, + { + "name": "symfony/yaml", + "version": "v2.5.4", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "01a7695bcfb013d0a15c6757e15aae120342986f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/01a7695bcfb013d0a15c6757e15aae120342986f", + "reference": "01a7695bcfb013d0a15c6757e15aae120342986f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2014-08-31 03:22:04" + } + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "prefer-stable": false, + "platform": [ + + ], + "platform-dev": [ + + ] +} diff --git a/spec/InfluxDB/Adapter/UdpSpec.php b/spec/InfluxDB/Adapter/UdpSpec.php new file mode 100644 index 000000000..9f3c9f08a --- /dev/null +++ b/spec/InfluxDB/Adapter/UdpSpec.php @@ -0,0 +1,24 @@ +beConstructedWith(); + } + + function it_is_initializable() + { + $this->shouldHaveType('InfluxDB\Adapter\Udp'); + } + + function it_should_implement_adapter_interface() + { + $this->shouldImplement("InfluxDB\Adapter\AdapterInterface"); + } +} diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php new file mode 100644 index 000000000..1af2fffb7 --- /dev/null +++ b/spec/InfluxDB/ClientSpec.php @@ -0,0 +1,39 @@ +setAdapter($adapter); + } + function it_is_initializable() + { + $this->shouldHaveType('InfluxDB\Client'); + } + + function it_should_implement_client_interface() + { + $this->shouldImplement("InfluxDB\ClientInterface"); + } + + function it_should_send_data(\InfluxDB\Adapter\AdapterInterface $adapter) + { + $adapter->send([ + "name" => "video.search", + "columns" => ["author", "title"], + "points" => [ + ["Guccini", "Autogrill"] + ] + ])->shouldBeCalledTimes(1); + + $this->mark("video.search", [ + "author" => "Guccini", + "title" => "Autogrill" + ]); + } +} diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php new file mode 100644 index 000000000..a1509c311 --- /dev/null +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -0,0 +1,13 @@ +host = $host; + $this->port = $port; + $this->username = $user; + $this->password = $password; + } + + public function getSocket() + { + return $this->socket; + } + + public function getName() + { + return $this->name; + } + + public function connect() + { + $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + return $this; + } + + public function disconnect() + { + socket_close($this->getSocket()); + } + + public function send($message) + { + socket_sendto($this->getSocket(), $message, strlen($message), 0, $this->host, $this->port); + } +} diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php new file mode 100644 index 000000000..884d8a9a6 --- /dev/null +++ b/src/InfluxDB/Client.php @@ -0,0 +1,39 @@ +adapter = $adapter; + return $this; + } + + public function getAdapter() + { + return $this->adapter; + } + + public function connect() + { + return $this->getAdapter()->connect(); + } + + public function disconnect() + { + return $this->getAdapter()->disconnect(); + } + + public function mark($name, array $values) + { + $data = []; + $data['name'] = $name; + $data['columns'] = array_keys($values); + $data['points'][] = array_values($values); + + return $this->getAdapter()->send($data); + } +} diff --git a/src/InfluxDB/ClientInterface.php b/src/InfluxDB/ClientInterface.php new file mode 100644 index 000000000..021c5eb2b --- /dev/null +++ b/src/InfluxDB/ClientInterface.php @@ -0,0 +1,11 @@ + Date: Wed, 10 Sep 2014 12:47:26 +0200 Subject: [PATCH 002/158] BUGFIX message --- spec/InfluxDB/ClientSpec.php | 4 ++-- src/InfluxDB/Adapter/Udp.php | 1 + src/InfluxDB/Client.php | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index 1af2fffb7..fc34b91ec 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -23,13 +23,13 @@ class ClientSpec extends ObjectBehavior function it_should_send_data(\InfluxDB\Adapter\AdapterInterface $adapter) { - $adapter->send([ + $adapter->send([[ "name" => "video.search", "columns" => ["author", "title"], "points" => [ ["Guccini", "Autogrill"] ] - ])->shouldBeCalledTimes(1); + ]])->shouldBeCalledTimes(1); $this->mark("video.search", [ "author" => "Guccini", diff --git a/src/InfluxDB/Adapter/Udp.php b/src/InfluxDB/Adapter/Udp.php index 63cddff37..5afd301fc 100644 --- a/src/InfluxDB/Adapter/Udp.php +++ b/src/InfluxDB/Adapter/Udp.php @@ -47,6 +47,7 @@ class Udp implements AdapterInterface public function send($message) { + $message = json_encode($message); socket_sendto($this->getSocket(), $message, strlen($message), 0, $this->host, $this->port); } } diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 884d8a9a6..3965b643b 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -29,11 +29,11 @@ class Client implements ClientInterface public function mark($name, array $values) { - $data = []; + $data =[]; $data['name'] = $name; $data['columns'] = array_keys($values); $data['points'][] = array_values($values); - return $this->getAdapter()->send($data); + return $this->getAdapter()->send([$data]); } } From 7733cd1743cc477fb4faef8674d432ad80caf812 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Wed, 10 Sep 2014 12:55:29 +0200 Subject: [PATCH 003/158] Change name of Udp adapter in UdpAdapter, add readme.md --- README.md | 11 +++++++++++ .../Adapter/{UdpSpec.php => UdpAdapterSpec.php} | 4 ++-- src/InfluxDB/Adapter/{Udp.php => UdpAdapter.php} | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 README.md rename spec/InfluxDB/Adapter/{UdpSpec.php => UdpAdapterSpec.php} (76%) rename src/InfluxDB/Adapter/{Udp.php => UdpAdapter.php} (95%) diff --git a/README.md b/README.md new file mode 100644 index 000000000..c5380a0f5 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# InfluxDB PHP SDK +Send message to InfluxDB. + +```php +$client = new \InfluxDB\Client(); +$client->setAdapter(new \InfluxDB\Adapter\UdpAdapter()); +$client->mark("search", [ + "query" => "php" +]); +``` + diff --git a/spec/InfluxDB/Adapter/UdpSpec.php b/spec/InfluxDB/Adapter/UdpAdapterSpec.php similarity index 76% rename from spec/InfluxDB/Adapter/UdpSpec.php rename to spec/InfluxDB/Adapter/UdpAdapterSpec.php index 9f3c9f08a..1e65698b9 100644 --- a/spec/InfluxDB/Adapter/UdpSpec.php +++ b/spec/InfluxDB/Adapter/UdpAdapterSpec.php @@ -5,7 +5,7 @@ namespace spec\InfluxDB\Adapter; use PhpSpec\ObjectBehavior; use Prophecy\Argument; -class UdpSpec extends ObjectBehavior +class UdpAdapterSpec extends ObjectBehavior { function let() { @@ -14,7 +14,7 @@ class UdpSpec extends ObjectBehavior function it_is_initializable() { - $this->shouldHaveType('InfluxDB\Adapter\Udp'); + $this->shouldHaveType('InfluxDB\Adapter\UdpAdapter'); } function it_should_implement_adapter_interface() diff --git a/src/InfluxDB/Adapter/Udp.php b/src/InfluxDB/Adapter/UdpAdapter.php similarity index 95% rename from src/InfluxDB/Adapter/Udp.php rename to src/InfluxDB/Adapter/UdpAdapter.php index 5afd301fc..661e2e064 100644 --- a/src/InfluxDB/Adapter/Udp.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -2,7 +2,7 @@ namespace InfluxDB\Adapter; -class Udp implements AdapterInterface +class UdpAdapter implements AdapterInterface { private $host; private $port; From 066a274801a27cd29eefc09bba08f19bb61b028b Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Wed, 10 Sep 2014 15:16:45 +0200 Subject: [PATCH 004/158] Add travis.yml support --- .travis.yml | 12 ++++++++++++ README.md | 1 + 2 files changed, 13 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..9473c3205 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: php + +php: + - 5.5 + - 5.6 + +before_script: + - composer selfupdate + - composer install --prefer-source + +script: + - vendor/bin/phpspec run diff --git a/README.md b/README.md index c5380a0f5..7b53c6ecd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # InfluxDB PHP SDK +[![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) [![Dependency Status](https://www.versioneye.com/user/projects/54104e789e1622492d000025/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54104e789e1622492d000025) Send message to InfluxDB. ```php From 47b8aba28f31c1e56cba20057898ee1e1a165b7b Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Sep 2014 09:50:43 +0200 Subject: [PATCH 005/158] Added license --- LICENSE | 19 +++++++++++++++++++ README.md | 27 +++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..a29931ccd --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Corley S.r.l. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 7b53c6ecd..6d4a9547d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,35 @@ # InfluxDB PHP SDK -[![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) [![Dependency Status](https://www.versioneye.com/user/projects/54104e789e1622492d000025/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54104e789e1622492d000025) -Send message to InfluxDB. + + * [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) + * [![Dependency Status](https://www.versioneye.com/user/projects/54104e789e1622492d000025/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54104e789e1622492d000025) + +Send metrics to InfluxDB. ```php $client = new \InfluxDB\Client(); $client->setAdapter(new \InfluxDB\Adapter\UdpAdapter()); + $client->mark("search", [ "query" => "php" ]); ``` +## Install it + +Just use composer + +```shell +php composer.phar require corley/influxdb-sdk:* +``` + +Or place it in your require section + +```json +{ + "require": { + // ... + "corley/influxdb-sdk": "*" + } +} +``` + From 5d2c1d852e81869b40c9e343985521fdf17e4319 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Sep 2014 09:50:53 +0200 Subject: [PATCH 006/158] Minor changes on composer --- composer.json | 5 ++++- src/InfluxDB/Client.php | 4 ++-- src/InfluxDB/ClientInterface.php | 11 ----------- 3 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 src/InfluxDB/ClientInterface.php diff --git a/composer.json b/composer.json index 13851b357..c9db8a5a6 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,12 @@ { "name": "corley/influxdb-sdk", - "description": "InfluxDb PHP sdk for send messages", + "license": "MIT", + "description": "Send your app metrics to InfluxDB", "require-dev": { "phpspec/phpspec": "2.*" }, + "homepage": "http://www.corley.it/", + "keywords": ["influxdb", "udp", "sdk"], "authors": [ { "name": "Gianluca Arbezzano", diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 3965b643b..7afed5d2a 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -20,7 +20,7 @@ class Client implements ClientInterface public function connect() { return $this->getAdapter()->connect(); - } + } public function disconnect() { @@ -29,7 +29,7 @@ class Client implements ClientInterface public function mark($name, array $values) { - $data =[]; + $data =[]; $data['name'] = $name; $data['columns'] = array_keys($values); $data['points'][] = array_values($values); diff --git a/src/InfluxDB/ClientInterface.php b/src/InfluxDB/ClientInterface.php deleted file mode 100644 index 021c5eb2b..000000000 --- a/src/InfluxDB/ClientInterface.php +++ /dev/null @@ -1,11 +0,0 @@ - Date: Thu, 11 Sep 2014 09:59:33 +0200 Subject: [PATCH 007/158] Removed client interface --- spec/InfluxDB/ClientSpec.php | 11 +++-------- src/InfluxDB/Client.php | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index fc34b91ec..ce1918e31 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -9,17 +9,12 @@ class ClientSpec extends ObjectBehavior { function let(\InfluxDB\Adapter\AdapterInterface $adapter) { - $this->setAdapter($adapter); + $this->setAdapter($adapter); } function it_is_initializable() { $this->shouldHaveType('InfluxDB\Client'); } - - function it_should_implement_client_interface() - { - $this->shouldImplement("InfluxDB\ClientInterface"); - } function it_should_send_data(\InfluxDB\Adapter\AdapterInterface $adapter) { @@ -28,12 +23,12 @@ class ClientSpec extends ObjectBehavior "columns" => ["author", "title"], "points" => [ ["Guccini", "Autogrill"] - ] + ] ]])->shouldBeCalledTimes(1); $this->mark("video.search", [ "author" => "Guccini", "title" => "Autogrill" - ]); + ]); } } diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 7afed5d2a..e92a889fb 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -2,7 +2,7 @@ namespace InfluxDB; -class Client implements ClientInterface +class Client { private $adapter; From 8bd15a302a8e92c8b75d00c2a363818661c77e88 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Sep 2014 14:50:31 +0200 Subject: [PATCH 008/158] Added HTTP client --- .gitignore | 1 + .travis.yml | 10 + README.md | 36 + composer.json | 10 +- composer.lock | 967 +++++++++++++++++- phpunit.xml.dist | 20 + spec/InfluxDB/Adapter/GuzzleAdapterSpec.php | 29 + spec/InfluxDB/Adapter/UdpAdapterSpec.php | 6 +- spec/InfluxDB/OptionsSpec.php | 37 + src/InfluxDB/Adapter/AdapterInterface.php | 8 +- src/InfluxDB/Adapter/ConnectableInterface.php | 8 + src/InfluxDB/Adapter/GuzzleAdapter.php | 40 + src/InfluxDB/Adapter/UdpAdapter.php | 31 +- src/InfluxDB/Options.php | 89 ++ tests/InfluxDB/ClientTest.php | 61 ++ tests/bootstrap.php | 11 + 16 files changed, 1325 insertions(+), 39 deletions(-) create mode 100644 phpunit.xml.dist create mode 100644 spec/InfluxDB/Adapter/GuzzleAdapterSpec.php create mode 100644 spec/InfluxDB/OptionsSpec.php create mode 100644 src/InfluxDB/Adapter/ConnectableInterface.php create mode 100644 src/InfluxDB/Adapter/GuzzleAdapter.php create mode 100644 src/InfluxDB/Options.php create mode 100644 tests/InfluxDB/ClientTest.php create mode 100644 tests/bootstrap.php diff --git a/.gitignore b/.gitignore index 22d0d82f8..54527ba06 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor +tags diff --git a/.travis.yml b/.travis.yml index 9473c3205..38b665b5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,19 @@ php: - 5.5 - 5.6 +before_install: + - sudo apt-get update + - sudo apt-get install libcurl4-openssl-dev libjson0-dev + - wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb + - sudo useradd influxdb + - sudo dpkg -i influxdb_latest_amd64.deb + - travis_retry sudo service influxdb restart + - sudo service influxdb status + before_script: - composer selfupdate - composer install --prefer-source script: - vendor/bin/phpspec run + - vendor/bin/phpunit diff --git a/README.md b/README.md index 6d4a9547d..0bca6b8dd 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,39 @@ Or place it in your require section } ``` +## Send data using HTTP json API + +Actually we using Guzzle as HTTP client + +```php +$influx->mark("tcp.test", ["mark" => "element"]); +``` + +## Prepare lib dependencies + +Use your DiC or Service Locator in order to provide a configured client + +```php +setHost("analytics.mine.domain.tld"); +$options->setPort(8086); +$options->setUsername("root"); +$options->setPassword("root"); + +$guzzleHttp = new GuzzleHttpClient(); +$adapter = new GuzzleAdapter($guzzleHttp, $options); +$adapter->setDatabase("mine"); + +$influx = new Client(); +$influx->setAdapter($adapter); + +$influx->mark("tcp.test", ["mark" => "element"]); +``` + diff --git a/composer.json b/composer.json index c9db8a5a6..758ac8fdb 100644 --- a/composer.json +++ b/composer.json @@ -2,8 +2,14 @@ "name": "corley/influxdb-sdk", "license": "MIT", "description": "Send your app metrics to InfluxDB", + "require": { + "guzzlehttp/guzzle": "~4" + }, "require-dev": { - "phpspec/phpspec": "2.*" + "phpspec/phpspec": "2.*", + "phpunit/phpunit": "4.*", + "zendframework/zend-stdlib": "~2", + "crodas/influx-php": "dev-master" }, "homepage": "http://www.corley.it/", "keywords": ["influxdb", "udp", "sdk"], @@ -23,7 +29,7 @@ ], "autoload": { "psr-0": { - "InfluxDB": "./src/" + "InfluxDB": ["./src/", "./tests"] } } } diff --git a/composer.lock b/composer.lock index 4abb61a3f..57dd307bc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,11 +4,274 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ebef29b39aea3cab015d3bf51e00121e", + "hash": "6ba22c8acf314366cc2d58a2cfaccbd3", "packages": [ - + { + "name": "guzzlehttp/guzzle", + "version": "4.2.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "9c4fbbf6457768f5036fbd88f1229f3fca812a5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9c4fbbf6457768f5036fbd88f1229f3fca812a5d", + "reference": "9c4fbbf6457768f5036fbd88f1229f3fca812a5d", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/streams": "~2.1", + "php": ">=5.4.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "~4.0", + "psr/log": "~1.0" + }, + "suggest": { + "ext-curl": "Guzzle will use specific adapters if cURL is present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2014-09-08 22:11:58" + }, + { + "name": "guzzlehttp/streams", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/streams.git", + "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/streams/zipball/f91b721d73f0e561410903b3b3c90a5d0e40b534", + "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Stream\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Provides a simple abstraction over streams of data (Guzzle 4+)", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "Guzzle", + "stream" + ], + "time": "2014-08-17 21:15:53" + } ], "packages-dev": [ + { + "name": "crodas/influx-php", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/crodas/InfluxPHP.git", + "reference": "205bd51cb44dec70d0da06ba87e47f5c0986bdb4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/crodas/InfluxPHP/zipball/205bd51cb44dec70d0da06ba87e47f5c0986bdb4", + "reference": "205bd51cb44dec70d0da06ba87e47f5c0986bdb4", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "authors": [ + { + "name": "César D. Rodas", + "email": "crodas@php.net" + } + ], + "description": "Simple client for InfluxDB", + "time": "2014-09-04 17:26:53" + }, + { + "name": "ocramius/instantiator", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/Instantiator.git", + "reference": "e24a12178906ff2e7471b8aaf3a0eb789b59f881" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/Instantiator/zipball/e24a12178906ff2e7471b8aaf3a0eb789b59f881", + "reference": "e24a12178906ff2e7471b8aaf3a0eb789b59f881", + "shasum": "" + }, + "require": { + "ocramius/lazy-map": "1.0.*", + "php": "~5.3" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/Ocramius/Instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-08-25 14:48:16" + }, + { + "name": "ocramius/lazy-map", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/LazyMap.git", + "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/LazyMap/zipball/7fe3d347f5e618bcea7d39345ff83f3651d8b752", + "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "athletic/athletic": "~0.1.6", + "phpmd/phpmd": "1.5.*", + "phpunit/phpunit": ">=3.7", + "satooshi/php-coveralls": "~0.6", + "squizlabs/php_codesniffer": "1.4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "LazyMap\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/", + "role": "Developer" + } + ], + "description": "A library that provides lazy instantiation logic for a map of objects", + "homepage": "https://github.com/Ocramius/LazyMap", + "keywords": [ + "lazy", + "lazy instantiation", + "lazy loading", + "map", + "service location" + ], + "time": "2013-11-09 22:30:54" + }, { "name": "phpdocumentor/reflection-docblock", "version": "2.0.3", @@ -223,6 +486,650 @@ ], "time": "2014-07-18 21:26:55" }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.11", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4.1" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2014-08-31 06:33:04" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2014-08-31 06:12:13" + }, + { + "name": "phpunit/phpunit", + "version": "4.2.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "c3abe5953d1e60a0bf23012b1bc8c4d07f4832d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c3abe5953d1e60a0bf23012b1bc8c4d07f4832d7", + "reference": "c3abe5953d1e60a0bf23012b1bc8c4d07f4832d7", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.2", + "sebastian/comparator": "~1.0", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.0", + "sebastian/exporter": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-09-06 18:38:27" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "b241b18d87a47093f20fae8b0ba40379b00bd53a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b241b18d87a47093f20fae8b0ba40379b00bd53a", + "reference": "b241b18d87a47093f20fae8b0ba40379b00bd53a", + "shasum": "" + }, + "require": { + "ocramius/instantiator": "~1.0", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2014-09-06 17:32:37" + }, + { + "name": "sebastian/comparator", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.1", + "sebastian/exporter": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2014-05-02 07:05:58" + }, + { + "name": "sebastian/diff", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2013-08-03 16:46:33" + }, + { + "name": "sebastian/environment", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2014-02-18 16:17:19" + }, + { + "name": "sebastian/exporter", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*@dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net", + "role": "Lead" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2014-02-16 08:26:31" + }, + { + "name": "sebastian/version", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2014-03-07 15:35:33" + }, { "name": "symfony/console", "version": "v2.5.4", @@ -428,15 +1335,65 @@ "description": "Symfony Yaml Component", "homepage": "http://symfony.com", "time": "2014-08-31 03:22:04" + }, + { + "name": "zendframework/zend-stdlib", + "version": "2.3.1", + "target-dir": "Zend/Stdlib", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendStdlib.git", + "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/c1f4830018b5d4f034d32fa01a9e17ea176f56f6", + "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6", + "shasum": "" + }, + "require": { + "php": ">=5.3.23" + }, + "require-dev": { + "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-serializer": "self.version", + "zendframework/zend-servicemanager": "self.version" + }, + "suggest": { + "zendframework/zend-eventmanager": "To support aggregate hydrator usage", + "zendframework/zend-serializer": "Zend\\Serializer component", + "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Stdlib\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "stdlib", + "zf2" + ], + "time": "2014-04-15 15:28:48" } ], "aliases": [ ], "minimum-stability": "stable", - "stability-flags": [ - - ], + "stability-flags": { + "crodas/influx-php": 20 + }, "prefer-stable": false, "platform": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000000000..ada74cb23 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,20 @@ + + + + tests + + + + + src + + + diff --git a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php new file mode 100644 index 000000000..9cc94be79 --- /dev/null +++ b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php @@ -0,0 +1,29 @@ +getTcpEndpointFor(Argument::Any())->willReturn("localhost"); + $this->beConstructedWith($client, $options); + } + + function it_is_initializable() + { + $this->shouldHaveType('InfluxDB\Adapter\GuzzleAdapter'); + } + + function it_should_send_data_via_post(Client $client, Options $options) + { + $client->post("localhost", ['body' => json_encode(['pippo'])])->shouldBeCalledTimes(1); + + $this->send(["pippo"]); + } +} diff --git a/spec/InfluxDB/Adapter/UdpAdapterSpec.php b/spec/InfluxDB/Adapter/UdpAdapterSpec.php index 1e65698b9..5d1aefc6a 100644 --- a/spec/InfluxDB/Adapter/UdpAdapterSpec.php +++ b/spec/InfluxDB/Adapter/UdpAdapterSpec.php @@ -4,12 +4,13 @@ namespace spec\InfluxDB\Adapter; use PhpSpec\ObjectBehavior; use Prophecy\Argument; +use InfluxDB\Options; class UdpAdapterSpec extends ObjectBehavior { - function let() + function let(Options $options) { - $this->beConstructedWith(); + $this->beConstructedWith($options); } function it_is_initializable() @@ -20,5 +21,6 @@ class UdpAdapterSpec extends ObjectBehavior function it_should_implement_adapter_interface() { $this->shouldImplement("InfluxDB\Adapter\AdapterInterface"); + $this->shouldImplement("InfluxDB\Adapter\ConnectableInterface"); } } diff --git a/spec/InfluxDB/OptionsSpec.php b/spec/InfluxDB/OptionsSpec.php new file mode 100644 index 000000000..bca74574f --- /dev/null +++ b/spec/InfluxDB/OptionsSpec.php @@ -0,0 +1,37 @@ +shouldHaveType('InfluxDB\Options'); + } + + function it_should_create_a_valid_tcp_endpoint() + { + $this->getTcpEndpointFor("mine") + ->shouldReturn("http://localhost:1806/db/mine/series?u=root&p=root"); + } + + function it_should_allows_option_override_for_tcp_endpoint() + { + $this->setHost("influx.1.prod.tld"); + $this->setPort(19385); + $this->setUsername("walter"); + $this->setPassword("walter"); + $this->getTcpEndpointFor("me") + ->shouldReturn("http://influx.1.prod.tld:19385/db/me/series?u=walter&p=walter"); + } + + function it_should_allows_https_for_tcp_endpoint() + { + $this->setProtocol("https"); + $this->getTcpEndpointFor("me") + ->shouldReturn("https://localhost:1806/db/me/series?u=root&p=root"); + } +} diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php index a1509c311..764bca1f6 100644 --- a/src/InfluxDB/Adapter/AdapterInterface.php +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -1,13 +1,7 @@ httpClient = $httpClient; + $this->options = $options; + } + + public function getDatabase() + { + return $this->database; + } + + public function setDatabase($database) + { + $this->database = $database; + return $this; + } + + public function send($message) + { + $httpMessage = [ + "body" => json_encode($message) + ]; + $endpoint = $this->options->getTcpEndpointFor($this->getDatabase()); + + $this->httpClient->post($endpoint, $httpMessage); + } +} diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index 661e2e064..729be12c6 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -2,26 +2,16 @@ namespace InfluxDB\Adapter; -class UdpAdapter implements AdapterInterface +use InfluxDB\Options; + +class UdpAdapter implements AdapterInterface, ConnectableInterface { - private $host; - private $port; - private $username; - private $password; - private $name = __NAMESPACE__; + private $options; private $socket; - public function __construct( - $host = "127.0.0.1", - $port = 5551, - $user = "root", - $password = "root" - ) + public function __construct(Options $options) { - $this->host = $host; - $this->port = $port; - $this->username = $user; - $this->password = $password; + $this->options = $options; } public function getSocket() @@ -29,11 +19,6 @@ class UdpAdapter implements AdapterInterface return $this->socket; } - public function getName() - { - return $this->name; - } - public function connect() { $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); @@ -42,12 +27,12 @@ class UdpAdapter implements AdapterInterface public function disconnect() { - socket_close($this->getSocket()); + socket_close($this->getSocket()); } public function send($message) { $message = json_encode($message); socket_sendto($this->getSocket(), $message, strlen($message), 0, $this->host, $this->port); - } + } } diff --git a/src/InfluxDB/Options.php b/src/InfluxDB/Options.php new file mode 100644 index 000000000..5acaebf23 --- /dev/null +++ b/src/InfluxDB/Options.php @@ -0,0 +1,89 @@ +host = "localhost"; + $this->port = 8086; + $this->username = "root"; + $this->password = "root"; + $this->setProtocol("http"); + } + + public function getProtocol() + { + return $this->protocol; + } + + public function setProtocol($protocol) + { + $this->protocol = $protocol; + return $this; + } + + public function getHost() + { + return $this->host; + } + + public function setHost($host) + { + $this->host = $host; + return $this; + } + + public function getPort() + { + return $this->port; + } + + public function setPort($port) + { + $this->port = $port; + return $this; + } + + public function getUsername() + { + return $this->username; + } + + public function setUsername($username) + { + $this->username = $username; + return $this; + } + + public function getPassword() + { + return $this->password; + } + + public function setPassword($password) + { + $this->password = $password; + return $this; + } + + public function getTcpEndpointFor($database) + { + return sprintf( + "%s://%s:%d/db/%s/series?u=%s&p=%s", + $this->getProtocol(), + $this->getHost(), + $this->getPort(), + $database, + $this->getUsername(), + $this->getPassword() + ); + } +} diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php new file mode 100644 index 000000000..e7226baf9 --- /dev/null +++ b/tests/InfluxDB/ClientTest.php @@ -0,0 +1,61 @@ +options = $options; + + $this->object = new Client(); + $this->hydrator = new ArraySerializable(); + + $client = new Crodas( + $options["tcp"]["host"], + $options["tcp"]["port"], + $options["tcp"]["username"], + $options["tcp"]["password"] + ); + $client->deleteDatabase($options["tcp"]["database"]); + $client->createDatabase($options["tcp"]["database"]); + + $this->anotherClient = $client; + } + + public function testHttpApiWorksCorrectly() + { + $tcpOptions = $this->options["tcp"]; + + $options = new Options(); + $options->setHost($tcpOptions["host"]); + $options->setPort($tcpOptions["port"]); + $options->setUsername($tcpOptions["username"]); + $options->setPassword($tcpOptions["password"]); + + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new GuzzleAdapter($guzzleHttp, $options); + $adapter->setDatabase($tcpOptions["database"]); + + $influx = new Client(); + $influx->setAdapter($adapter); + + $influx->mark("tcp.test", ["mark" => "element"]); + + $cursor = $this->anotherClient->getDatabase("mine")->query("select * from tcp.test"); + $this->assertCount(1, $cursor); + $this->assertEquals("element", $cursor[0]->mark); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 000000000..cf38911f3 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,11 @@ + [ + "host" => "localhost", + "port" => 8086, + "protocol" => "http", + "database" => "mine", + "username" => "root", + "password" => "root", + ] +]; From 2aad2b1bb0513bcb1af979006f0767ac52529fb4 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Sep 2014 15:06:53 +0200 Subject: [PATCH 009/158] Fixes infludb default port --- spec/InfluxDB/OptionsSpec.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/InfluxDB/OptionsSpec.php b/spec/InfluxDB/OptionsSpec.php index bca74574f..5ac0c4004 100644 --- a/spec/InfluxDB/OptionsSpec.php +++ b/spec/InfluxDB/OptionsSpec.php @@ -15,7 +15,7 @@ class OptionsSpec extends ObjectBehavior function it_should_create_a_valid_tcp_endpoint() { $this->getTcpEndpointFor("mine") - ->shouldReturn("http://localhost:1806/db/mine/series?u=root&p=root"); + ->shouldReturn("http://localhost:8086/db/mine/series?u=root&p=root"); } function it_should_allows_option_override_for_tcp_endpoint() @@ -32,6 +32,6 @@ class OptionsSpec extends ObjectBehavior { $this->setProtocol("https"); $this->getTcpEndpointFor("me") - ->shouldReturn("https://localhost:1806/db/me/series?u=root&p=root"); + ->shouldReturn("https://localhost:8086/db/me/series?u=root&p=root"); } } From 08a1b75ea240b3c99cff4751a2bc74100b006af6 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Sep 2014 15:13:12 +0200 Subject: [PATCH 010/158] Fixes exception missing database --- tests/InfluxDB/ClientTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index e7226baf9..34cb19ad5 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -29,7 +29,11 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options["tcp"]["username"], $options["tcp"]["password"] ); - $client->deleteDatabase($options["tcp"]["database"]); + try { + $client->deleteDatabase($options["tcp"]["database"]); + } catch (\Exception $e) { + // nothing... + } $client->createDatabase($options["tcp"]["database"]); $this->anotherClient = $client; From 16f8b9ec48a172b87d68b18897d1b49b69e99226 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Sep 2014 19:52:17 +0200 Subject: [PATCH 011/158] Fixes import guzzle as http client description --- README.md | 4 ++-- tests/InfluxDB/ClientTest.php | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0bca6b8dd..93e50a6b4 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Use your DiC or Service Locator in order to provide a configured client use InfluxDB\Client; use InfluxDB\Options; -use InfluxDB\Adapter\GuzzleAdapter; +use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter; use GuzzleHttp\Client as GuzzleHttpClient; $options = new Options(); @@ -60,7 +60,7 @@ $options->setUsername("root"); $options->setPassword("root"); $guzzleHttp = new GuzzleHttpClient(); -$adapter = new GuzzleAdapter($guzzleHttp, $options); +$adapter = new InfluxHttpAdapter($guzzleHttp, $options); $adapter->setDatabase("mine"); $influx = new Client(); diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 34cb19ad5..3125fedf0 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -1,17 +1,15 @@ options = $options; $this->object = new Client(); - $this->hydrator = new ArraySerializable(); $client = new Crodas( $options["tcp"]["host"], @@ -39,7 +36,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->anotherClient = $client; } - public function testHttpApiWorksCorrectly() + public function testGuzzleHttpApiWorksCorrectly() { $tcpOptions = $this->options["tcp"]; @@ -50,7 +47,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setPassword($tcpOptions["password"]); $guzzleHttp = new GuzzleHttpClient(); - $adapter = new GuzzleAdapter($guzzleHttp, $options); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); $adapter->setDatabase($tcpOptions["database"]); $influx = new Client(); @@ -58,7 +55,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase $influx->mark("tcp.test", ["mark" => "element"]); - $cursor = $this->anotherClient->getDatabase("mine")->query("select * from tcp.test"); + $cursor = $this->anotherClient->getDatabase($tcpOptions["database"]) + ->query("select * from tcp.test"); $this->assertCount(1, $cursor); $this->assertEquals("element", $cursor[0]->mark); } From ca09343134f4f2259e9e6b0fcc4d57bb6d24f267 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Sep 2014 08:24:21 +0200 Subject: [PATCH 012/158] Moved database into options --- README.md | 6 ++++-- composer.json | 5 +++++ composer.lock | 2 +- spec/InfluxDB/Adapter/GuzzleAdapterSpec.php | 2 +- spec/InfluxDB/OptionsSpec.php | 9 ++++++--- src/InfluxDB/Adapter/GuzzleAdapter.php | 13 +------------ src/InfluxDB/Options.php | 17 +++++++++++++++-- tests/InfluxDB/ClientTest.php | 2 +- 8 files changed, 34 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 93e50a6b4..c4603c7d5 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,10 @@ Send metrics to InfluxDB. ```php +$options = new \InfluxDB\Options(); + $client = new \InfluxDB\Client(); -$client->setAdapter(new \InfluxDB\Adapter\UdpAdapter()); +$client->setAdapter(new \InfluxDB\Adapter\UdpAdapter($options)); $client->mark("search", [ "query" => "php" @@ -58,10 +60,10 @@ $options->setHost("analytics.mine.domain.tld"); $options->setPort(8086); $options->setUsername("root"); $options->setPassword("root"); +$options->setDatabase("mine"); $guzzleHttp = new GuzzleHttpClient(); $adapter = new InfluxHttpAdapter($guzzleHttp, $options); -$adapter->setDatabase("mine"); $influx = new Client(); $influx->setAdapter($adapter); diff --git a/composer.json b/composer.json index 758ac8fdb..82c20d1f5 100644 --- a/composer.json +++ b/composer.json @@ -31,5 +31,10 @@ "psr-0": { "InfluxDB": ["./src/", "./tests"] } + }, + "suggests": { + "fabpot/pimple": "Allows to prepare the client dependencies in order to require an initialized instance", + "zendframework/zend-servicemanager": "Use a service locator in order to prepare a valid instance", + "symfony/dependency-injection": "Prepare a valid instance via the symfony DiC" } } diff --git a/composer.lock b/composer.lock index 57dd307bc..98d05b929 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6ba22c8acf314366cc2d58a2cfaccbd3", + "hash": "1b622dda38682502a547657384b6fe7f", "packages": [ { "name": "guzzlehttp/guzzle", diff --git a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php index 9cc94be79..73f8f0ffa 100644 --- a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php +++ b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php @@ -11,7 +11,7 @@ class GuzzleAdapterSpec extends ObjectBehavior { function let(Client $client, Options $options) { - $options->getTcpEndpointFor(Argument::Any())->willReturn("localhost"); + $options->getTcpEndpoint()->willReturn("localhost"); $this->beConstructedWith($client, $options); } diff --git a/spec/InfluxDB/OptionsSpec.php b/spec/InfluxDB/OptionsSpec.php index 5ac0c4004..44ea4fb4a 100644 --- a/spec/InfluxDB/OptionsSpec.php +++ b/spec/InfluxDB/OptionsSpec.php @@ -14,7 +14,8 @@ class OptionsSpec extends ObjectBehavior function it_should_create_a_valid_tcp_endpoint() { - $this->getTcpEndpointFor("mine") + $this->setDatabase("mine"); + $this->getTcpEndpoint() ->shouldReturn("http://localhost:8086/db/mine/series?u=root&p=root"); } @@ -24,14 +25,16 @@ class OptionsSpec extends ObjectBehavior $this->setPort(19385); $this->setUsername("walter"); $this->setPassword("walter"); - $this->getTcpEndpointFor("me") + $this->setDatabase("me"); + $this->getTcpEndpoint() ->shouldReturn("http://influx.1.prod.tld:19385/db/me/series?u=walter&p=walter"); } function it_should_allows_https_for_tcp_endpoint() { $this->setProtocol("https"); - $this->getTcpEndpointFor("me") + $this->setDatabase("me"); + $this->getTcpEndpoint() ->shouldReturn("https://localhost:8086/db/me/series?u=root&p=root"); } } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 9e69e726a..fc7bf7fb7 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -17,23 +17,12 @@ class GuzzleAdapter implements AdapterInterface $this->options = $options; } - public function getDatabase() - { - return $this->database; - } - - public function setDatabase($database) - { - $this->database = $database; - return $this; - } - public function send($message) { $httpMessage = [ "body" => json_encode($message) ]; - $endpoint = $this->options->getTcpEndpointFor($this->getDatabase()); + $endpoint = $this->options->getTcpEndpoint(); $this->httpClient->post($endpoint, $httpMessage); } diff --git a/src/InfluxDB/Options.php b/src/InfluxDB/Options.php index 5acaebf23..e084a1848 100644 --- a/src/InfluxDB/Options.php +++ b/src/InfluxDB/Options.php @@ -10,6 +10,8 @@ class Options private $password; private $protocol; + private $database; + public function __construct() { $this->host = "localhost"; @@ -74,14 +76,25 @@ class Options return $this; } - public function getTcpEndpointFor($database) + public function getDatabase() + { + return $this->database; + } + + public function setDatabase($database) + { + $this->database = $database; + return $this; + } + + public function getTcpEndpoint() { return sprintf( "%s://%s:%d/db/%s/series?u=%s&p=%s", $this->getProtocol(), $this->getHost(), $this->getPort(), - $database, + $this->getDatabase(), $this->getUsername(), $this->getPassword() ); diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 3125fedf0..05690b741 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -45,10 +45,10 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setPort($tcpOptions["port"]); $options->setUsername($tcpOptions["username"]); $options->setPassword($tcpOptions["password"]); + $options->setDatabase($tcpOptions["database"]); $guzzleHttp = new GuzzleHttpClient(); $adapter = new InfluxHttpAdapter($guzzleHttp, $options); - $adapter->setDatabase($tcpOptions["database"]); $influx = new Client(); $influx->setAdapter($adapter); From b835c3a044d155208027fde3d8d8e52a3f760f93 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Sep 2014 20:20:23 +0200 Subject: [PATCH 013/158] Added query method for Http adapter --- README.md | 45 ++++++++++++++++++ composer.json | 2 +- spec/InfluxDB/Adapter/GuzzleAdapterSpec.php | 21 ++++++++- spec/InfluxDB/ClientSpec.php | 33 +++++++++++++ spec/InfluxDB/OptionsSpec.php | 12 ++--- src/InfluxDB/Adapter/GuzzleAdapter.php | 23 ++++++++-- src/InfluxDB/Adapter/QueryableInterface.php | 7 +++ src/InfluxDB/Client.php | 27 +++++++++++ src/InfluxDB/Options.php | 8 ++-- tests/InfluxDB/ClientTest.php | 51 +++++++++++++++++---- 10 files changed, 203 insertions(+), 26 deletions(-) create mode 100644 src/InfluxDB/Adapter/QueryableInterface.php diff --git a/README.md b/README.md index c4603c7d5..f0ffe18c3 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,51 @@ Actually we using Guzzle as HTTP client $influx->mark("tcp.test", ["mark" => "element"]); ``` +## Query InfluxDB + +You can query the time series database using the query method. + +```php +$influx->query("select * from mine"); +$influx->query("select * from mine", "s"); // with time_precision +``` + +You can query the database only if the adapter is queryable (implements `QueryableInterface`), +actually `GuzzleAdapter`. + +The adapter returns the json decoded body of the InfluxDB response, something like: + +``` +array(1) { + [0] => + class stdClass#1 (3) { + public $name => + string(8) "tcp.test" + public $columns => + array(3) { + [0] => + string(4) "time" + [1] => + string(15) "sequence_number" + [2] => + string(4) "mark" + } + public $points => + array(1) { + [0] => + array(3) { + [0] => + int(1410545635590) + [1] => + int(2390001) + [2] => + string(7) "element" + } + } + } +} +``` + ## Prepare lib dependencies Use your DiC or Service Locator in order to provide a configured client diff --git a/composer.json b/composer.json index 82c20d1f5..e6b7245c2 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ ], "autoload": { "psr-0": { - "InfluxDB": ["./src/", "./tests"] + "InfluxDB\\": ["./src/", "./tests"] } }, "suggests": { diff --git a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php index 73f8f0ffa..3befd1b72 100644 --- a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php +++ b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php @@ -11,7 +11,9 @@ class GuzzleAdapterSpec extends ObjectBehavior { function let(Client $client, Options $options) { - $options->getTcpEndpoint()->willReturn("localhost"); + $options->getHttpSeriesEndpoint()->willReturn("localhost"); + $options->getUsername()->willReturn("one"); + $options->getPassword()->willReturn("two"); $this->beConstructedWith($client, $options); } @@ -22,8 +24,23 @@ class GuzzleAdapterSpec extends ObjectBehavior function it_should_send_data_via_post(Client $client, Options $options) { - $client->post("localhost", ['body' => json_encode(['pippo'])])->shouldBeCalledTimes(1); + $client->post("localhost", [ + 'auth' => ["one", "two"], + 'body' => json_encode(['pippo']) + ])->shouldBeCalledTimes(1); $this->send(["pippo"]); } + + function it_should_query_data(Client $client, Options $options) + { + $client->get("select * from tcp.test", [])->willReturn([]); + $this->query("select * from tcp.test")->shouldReturn([]); + } + + function it_should_query_data_with_time_precision(Client $client, Options $options) + { + $client->get("select * from tcp.test", ["time_precision" => "s"])->willReturn([]); + $this->query("select * from tcp.test", "s")->shouldReturn([]); + } } diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index ce1918e31..28a006d5d 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -4,6 +4,8 @@ namespace spec\InfluxDB; use PhpSpec\ObjectBehavior; use Prophecy\Argument; +use InfluxDB\Adapter\GuzzleAdapter; +use InfluxDB\Adapter\UdpAdapter; class ClientSpec extends ObjectBehavior { @@ -31,4 +33,35 @@ class ClientSpec extends ObjectBehavior "title" => "Autogrill" ]); } + + function it_should_query_on_querable_adapter(GuzzleAdapter $adapter) + { + $this->setAdapter($adapter); + $adapter->query("select * from tcp.test", false)->willReturn([]); + + $this->query("select * from tcp.test")->shouldReturn([]); + } + + function it_should_query_with_time_precision(GuzzleAdapter $adapter) + { + $this->setAdapter($adapter); + $adapter->query("select * from tcp.test", "s")->willReturn([]); + + $this->query("select * from tcp.test", "s")->shouldReturn([]); + } + + function it_should_query_but_skip_invalid_time_precision(GuzzleAdapter $adapter) + { + $this->setAdapter($adapter); + $adapter->query("select * from tcp.test", false)->willReturn([]); + + $this->query("select * from tcp.test", "r")->shouldReturn([]); + } + + function it_should_thrown_an_exception_on_unquerable_adapter(UdpAdapter $adapter) + { + $this->setAdapter($adapter); + + $this->shouldThrow("\\BadMethodCallException")->duringQuery("select * from tcp.test"); + } } diff --git a/spec/InfluxDB/OptionsSpec.php b/spec/InfluxDB/OptionsSpec.php index 44ea4fb4a..d926faf83 100644 --- a/spec/InfluxDB/OptionsSpec.php +++ b/spec/InfluxDB/OptionsSpec.php @@ -15,8 +15,8 @@ class OptionsSpec extends ObjectBehavior function it_should_create_a_valid_tcp_endpoint() { $this->setDatabase("mine"); - $this->getTcpEndpoint() - ->shouldReturn("http://localhost:8086/db/mine/series?u=root&p=root"); + $this->getHttpSeriesEndpoint() + ->shouldReturn("http://localhost:8086/db/mine/series"); } function it_should_allows_option_override_for_tcp_endpoint() @@ -26,15 +26,15 @@ class OptionsSpec extends ObjectBehavior $this->setUsername("walter"); $this->setPassword("walter"); $this->setDatabase("me"); - $this->getTcpEndpoint() - ->shouldReturn("http://influx.1.prod.tld:19385/db/me/series?u=walter&p=walter"); + $this->getHttpSeriesEndpoint() + ->shouldReturn("http://influx.1.prod.tld:19385/db/me/series"); } function it_should_allows_https_for_tcp_endpoint() { $this->setProtocol("https"); $this->setDatabase("me"); - $this->getTcpEndpoint() - ->shouldReturn("https://localhost:8086/db/me/series?u=root&p=root"); + $this->getHttpSeriesEndpoint() + ->shouldReturn("https://localhost:8086/db/me/series"); } } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index fc7bf7fb7..da27104d0 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -5,7 +5,7 @@ namespace InfluxDB\Adapter; use GuzzleHttp\Client; use InfluxDB\Options; -class GuzzleAdapter implements AdapterInterface +class GuzzleAdapter implements AdapterInterface, QueryableInterface { private $httpClient; private $options; @@ -20,10 +20,27 @@ class GuzzleAdapter implements AdapterInterface public function send($message) { $httpMessage = [ + "auth" => [$this->options->getUsername(), $this->options->getPassword()], "body" => json_encode($message) ]; - $endpoint = $this->options->getTcpEndpoint(); + $endpoint = $this->options->getHttpSeriesEndpoint(); - $this->httpClient->post($endpoint, $httpMessage); + return $this->httpClient->post($endpoint, $httpMessage); + } + + public function query($query, $timePrecision = false) + { + $options = [ + "auth" => [$this->options->getUsername(), $this->options->getPassword()], + 'query' => [ + "q" => $query, + ] + ]; + if ($timePrecision) { + $options["query"]["time_precision"] = $timePrecision; + } + + $endpoint = $this->options->getHttpSeriesEndpoint(); + return $this->httpClient->get($endpoint, $options)->json(); } } diff --git a/src/InfluxDB/Adapter/QueryableInterface.php b/src/InfluxDB/Adapter/QueryableInterface.php new file mode 100644 index 000000000..fa604b069 --- /dev/null +++ b/src/InfluxDB/Adapter/QueryableInterface.php @@ -0,0 +1,7 @@ +getAdapter()->send([$data]); } + + public function query($query, $timePrecision = false) + { + if (!($this->getAdapter() instanceOf QueryableInterface)) { + throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); + } + + $timePrecision = $this->clearTimePrecision($timePrecision); + + return $this->getAdapter()->query($query, $timePrecision); + } + + private function clearTimePrecision($timePrecision) + { + switch ($timePrecision) { + case 's': + case 'u': + case 'ms': + break; + default: + $timePrecision = false; + } + + return $timePrecision; + } } diff --git a/src/InfluxDB/Options.php b/src/InfluxDB/Options.php index e084a1848..02ff5ef44 100644 --- a/src/InfluxDB/Options.php +++ b/src/InfluxDB/Options.php @@ -87,16 +87,14 @@ class Options return $this; } - public function getTcpEndpoint() + public function getHttpSeriesEndpoint() { return sprintf( - "%s://%s:%d/db/%s/series?u=%s&p=%s", + "%s://%s:%d/db/%s/series", $this->getProtocol(), $this->getHost(), $this->getPort(), - $this->getDatabase(), - $this->getUsername(), - $this->getPassword() + $this->getDatabase() ); } } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 05690b741..ec6581510 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -16,9 +16,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase public function setUp() { $options = include __DIR__ . '/../bootstrap.php'; - $this->options = $options; - - $this->object = new Client(); $client = new Crodas( $options["tcp"]["host"], @@ -34,11 +31,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase $client->createDatabase($options["tcp"]["database"]); $this->anotherClient = $client; - } - public function testGuzzleHttpApiWorksCorrectly() - { - $tcpOptions = $this->options["tcp"]; + $tcpOptions = $options["tcp"]; $options = new Options(); $options->setHost($tcpOptions["host"]); @@ -47,17 +41,56 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setPassword($tcpOptions["password"]); $options->setDatabase($tcpOptions["database"]); + $this->options = $options; + $guzzleHttp = new GuzzleHttpClient(); $adapter = new InfluxHttpAdapter($guzzleHttp, $options); $influx = new Client(); $influx->setAdapter($adapter); + $this->object = $influx; + } - $influx->mark("tcp.test", ["mark" => "element"]); + public function testGuzzleHttpApiWorksCorrectly() + { + $this->object->mark("tcp.test", ["mark" => "element"]); - $cursor = $this->anotherClient->getDatabase($tcpOptions["database"]) + $cursor = $this->anotherClient->getDatabase($this->options->getDatabase()) ->query("select * from tcp.test"); $this->assertCount(1, $cursor); $this->assertEquals("element", $cursor[0]->mark); } + + public function testGuzzleHttpQueryApiWorksCorrectly() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select * from tcp.test"); + + $this->assertCount(1, $body); + $this->assertEquals("tcp.test", $body[0]["name"]); + $this->assertEquals("element", $body[0]["points"][0][2]); + } + + public function testGuzzleHttpQueryApiWithMultipleData() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + $this->object->mark("tcp.test", ["mark" => "element2"]); + $this->object->mark("tcp.test", ["mark" => "element3"]); + + $body = $this->object->query("select mark from tcp.test", "s"); + + $this->assertCount(3, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + } + + public function testGuzzleHttpQueryApiWithTimePrecision() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select mark from tcp.test", "s"); + + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + } } From eacc092debf596cf64060c61131888b38ed799eb Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Sep 2014 23:05:29 +0200 Subject: [PATCH 014/158] Fixes spec on guzzle adapter --- spec/InfluxDB/Adapter/GuzzleAdapterSpec.php | 26 +++++++++++++++++---- tests/InfluxDB/ClientTest.php | 7 +++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php index 3befd1b72..5c61ce1bb 100644 --- a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php +++ b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php @@ -6,6 +6,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use GuzzleHttp\Client; use InfluxDB\Options; +use GuzzleHttp\Message\Response; class GuzzleAdapterSpec extends ObjectBehavior { @@ -34,13 +35,30 @@ class GuzzleAdapterSpec extends ObjectBehavior function it_should_query_data(Client $client, Options $options) { - $client->get("select * from tcp.test", [])->willReturn([]); - $this->query("select * from tcp.test")->shouldReturn([]); + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(200,[],null)); + $this->query("select * from tcp.test")->shouldReturn(null); } function it_should_query_data_with_time_precision(Client $client, Options $options) { - $client->get("select * from tcp.test", ["time_precision" => "s"])->willReturn([]); - $this->query("select * from tcp.test", "s")->shouldReturn([]); + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "query" => [ + "time_precision" => "s", + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(200, [], null)); + $this->query("select * from tcp.test", "s")->shouldReturn(null); } } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index ec6581510..566150f7d 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -55,10 +55,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase { $this->object->mark("tcp.test", ["mark" => "element"]); - $cursor = $this->anotherClient->getDatabase($this->options->getDatabase()) - ->query("select * from tcp.test"); - $this->assertCount(1, $cursor); - $this->assertEquals("element", $cursor[0]->mark); + $body = $this->object->query("select * from tcp.test"); + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("element", $body[0]["points"][0][2]); } public function testGuzzleHttpQueryApiWorksCorrectly() From 5b5baf20dd2722d05aace1e25b118da9fe1f6128 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Sep 2014 23:22:37 +0200 Subject: [PATCH 015/158] Fixes wrong namespace for connectable --- spec/InfluxDB/ClientSpec.php | 28 +++++++++++++++++-- src/InfluxDB/Adapter/AdapterInterface.php | 2 +- src/InfluxDB/Adapter/ConnectableInterface.php | 2 +- src/InfluxDB/Adapter/GuzzleAdapter.php | 3 +- src/InfluxDB/Adapter/UdpAdapter.php | 1 - src/InfluxDB/Client.php | 15 ++++++++-- 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index 28a006d5d..888f21b8c 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -1,11 +1,12 @@ setAdapter($adapter); } + function it_is_initializable() { $this->shouldHaveType('InfluxDB\Client'); } - function it_should_send_data(\InfluxDB\Adapter\AdapterInterface $adapter) + function it_should_be_connectable(ConnectableInterface $adapter) + { + $adapter->connect()->willReturn(true)->shouldBeCalledTimes(1); + + $this->setAdapter($adapter); + $this->connect()->shouldReturn(true); + } + + function it_should_be_disconnectable(ConnectableInterface $adapter) + { + $adapter->disconnect()->willReturn(true)->shouldBeCalledTimes(1); + + $this->setAdapter($adapter); + $this->disconnect()->shouldReturn(true); + } + + function it_should_not_call_connect(AdapterInterface $adapter) + { + $this->setAdapter($adapter); + $this->connect()->shouldReturn(false); + } + + function it_should_send_data(AdapterInterface $adapter) { $adapter->send([[ "name" => "video.search", diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php index 764bca1f6..d0b9e539a 100644 --- a/src/InfluxDB/Adapter/AdapterInterface.php +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -1,5 +1,5 @@ [$this->options->getUsername(), $this->options->getPassword()], "body" => json_encode($message) ]; - $endpoint = $this->options->getHttpSeriesEndpoint(); + $endpoint = $this->options->getHttpSeriesEndpoint(); return $this->httpClient->post($endpoint, $httpMessage); } @@ -36,6 +36,7 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface "q" => $query, ] ]; + if ($timePrecision) { $options["query"]["time_precision"] = $timePrecision; } diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index 729be12c6..2cb026ede 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -1,5 +1,4 @@ getAdapter()->connect(); + $result = false; + if ($this->getAdapter() instanceOf ConnectableInterface) { + $result = $this->getAdapter()->connect(); + } + + return $result; } public function disconnect() { - return $this->getAdapter()->disconnect(); + $result = false; + if ($this->getAdapter() instanceOf ConnectableInterface) { + $result = $this->getAdapter()->disconnect(); + } + + return $result; } public function mark($name, array $values) From 723ff0ecd2c6d0550401bd9389b327f7a5192260 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Sep 2014 23:33:27 +0200 Subject: [PATCH 016/158] Updated readme.md --- README.md | 91 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index f0ffe18c3..6fc9ea862 100644 --- a/README.md +++ b/README.md @@ -3,47 +3,54 @@ * [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) * [![Dependency Status](https://www.versioneye.com/user/projects/54104e789e1622492d000025/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54104e789e1622492d000025) -Send metrics to InfluxDB. +Send metrics to InfluxDB and query for any data. + +Add new points: ```php -$options = new \InfluxDB\Options(); - -$client = new \InfluxDB\Client(); -$client->setAdapter(new \InfluxDB\Adapter\UdpAdapter($options)); - -$client->mark("search", [ - "query" => "php" +$client->mark("app.search", [ + "key" => "this is my search" ]); ``` -## Install it - -Just use composer - -```shell -php composer.phar require corley/influxdb-sdk:* -``` - -Or place it in your require section - -```json -{ - "require": { - // ... - "corley/influxdb-sdk": "*" - } -} -``` - -## Send data using HTTP json API - -Actually we using Guzzle as HTTP client +Retrieve existing points: ```php -$influx->mark("tcp.test", ["mark" => "element"]); +$results = $client->query("select * from app.search"); ``` -## Query InfluxDB +## InfluxDB client adapters + +Actually we supports two adapters + + * UDP/IP - in order to send data via UDP (datagram) + * HTTP JSON - in order to send/retrieve using HTTP (connection oriented) + +### Using UDP/IP Adapter + +Actually "socket" php library is used for UDP/IP adapter + +``` +$options = new Options(); +$adapter = new UdpAdapter($options); + +$client = new Client(); +$client->setAdapter($adapter); +``` + +### Using HTTP Adapter + +Actually Guzzle is used as HTTP client library + +``` +$options = new Options(); +$adapter = new GuzzleAdapter($options); + +$client = new Client(); +$client->setAdapter($adapter); +``` + +### Query InfluxDB You can query the time series database using the query method. @@ -88,6 +95,26 @@ array(1) { } ``` +## Install it + +Just use composer + +```shell +php composer.phar require corley/influxdb-sdk:dev-master +``` + +Or place it in your require section + +```json +{ + "require": { + // ... + "corley/influxdb-sdk": "dev-master" + } +} +``` + + ## Prepare lib dependencies Use your DiC or Service Locator in order to provide a configured client From 1a06353b24ed1f137f8b6442b2da1f18e02cb8d0 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 00:10:45 +0200 Subject: [PATCH 017/158] Removed connectable interface --- .travis.yml | 1 + scripts/influxdb_conf.toml | 187 ++++++++++++++++++ src/InfluxDB/Adapter/ConnectableInterface.php | 8 - src/InfluxDB/Adapter/GuzzleAdapter.php | 5 + src/InfluxDB/Adapter/UdpAdapter.php | 23 +-- src/InfluxDB/Client.php | 20 -- tests/InfluxDB/ClientTest.php | 51 +++++ tests/bootstrap.php | 9 +- 8 files changed, 256 insertions(+), 48 deletions(-) create mode 100644 scripts/influxdb_conf.toml delete mode 100644 src/InfluxDB/Adapter/ConnectableInterface.php diff --git a/.travis.yml b/.travis.yml index 38b665b5b..bc5c8ba79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ before_install: - wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb - sudo useradd influxdb - sudo dpkg -i influxdb_latest_amd64.deb + - sudo cp ./scripts/influxdb_conf.toml /opt/influxdb/shared/config.toml - travis_retry sudo service influxdb restart - sudo service influxdb status diff --git a/scripts/influxdb_conf.toml b/scripts/influxdb_conf.toml new file mode 100644 index 000000000..e0c505a7b --- /dev/null +++ b/scripts/influxdb_conf.toml @@ -0,0 +1,187 @@ +# Welcome to the InfluxDB configuration file. + +# If hostname (on the OS) doesn't return a name that can be resolved by the other +# systems in the cluster, you'll have to set the hostname to an IP or something +# that can be resolved here. +# hostname = "" + +bind-address = "0.0.0.0" + +# Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com +# The data includes raft name (random 8 bytes), os, arch and version +# We don't track ip addresses of servers reporting. This is only used +# to track the number of instances running and the versions which +# is very helpful for us. +# Change this option to true to disable reporting. +reporting-disabled = false + +[logging] +# logging level can be one of "debug", "info", "warn" or "error" +level = "info" +file = "/opt/influxdb/shared/log.txt" # stdout to log to standard out + +# Configure the admin server +[admin] +port = 8083 # binding is disabled if the port isn't set +assets = "/opt/influxdb/current/admin" + +# Configure the http api +[api] +port = 8086 # binding is disabled if the port isn't set +# ssl-port = 8084 # Ssl support is enabled if you set a port and cert +# ssl-cert = /path/to/cert.pem + +# connections will timeout after this amount of time. Ensures that clients that misbehave +# and keep alive connections they don't use won't end up connection a million times. +# However, if a request is taking longer than this to complete, could be a problem. +read-timeout = "5s" + +[input_plugins] + + # Configure the graphite api + [input_plugins.graphite] + enabled = false + # port = 2003 + # database = "" # store graphite data in this database + # udp_enabled = true # enable udp interface on the same port as the tcp interface + + # Configure the udp api + #[input_plugins.udp] + #enabled = true + #port = 4444 + # database = "" + + # Configure multiple udp apis each can write to separate db. Just + # repeat the following section to enable multiple udp apis on + # different ports. + [[input_plugins.udp_servers]] # array of tables + enabled = true + port = 5551 + database = "mine" + +# Raft configuration +[raft] +# The raft port should be open between all servers in a cluster. +# However, this port shouldn't be accessible from the internet. + +port = 8090 + +# Where the raft logs are stored. The user running InfluxDB will need read/write access. +dir = "/opt/influxdb/shared/data/raft" + +# election-timeout = "1s" + +[storage] + +dir = "/opt/influxdb/shared/data/db" +# How many requests to potentially buffer in memory. If the buffer gets filled then writes +# will still be logged and once the local storage has caught up (or compacted) the writes +# will be replayed from the WAL +write-buffer-size = 10000 + +# the engine to use for new shards, old shards will continue to use the same engine +default-engine = "rocksdb" + +# The default setting on this is 0, which means unlimited. Set this to something if you want to +# limit the max number of open files. max-open-files is per shard so this * that will be max. +max-open-shards = 0 + +# The default setting is 100. This option tells how many points will be fetched from LevelDb before +# they get flushed into backend. +point-batch-size = 100 + +# The number of points to batch in memory before writing them to leveldb. Lowering this number will +# reduce the memory usage, but will result in slower writes. +write-batch-size = 5000000 + +# The server will check this often for shards that have expired that should be cleared. +retention-sweep-period = "10m" + +[storage.engines.leveldb] + +# Maximum mmap open files, this will affect the virtual memory used by +# the process +max-open-files = 1000 + +# LRU cache size, LRU is used by leveldb to store contents of the +# uncompressed sstables. You can use `m` or `g` prefix for megabytes +# and gigabytes, respectively. +lru-cache-size = "200m" + +[storage.engines.rocksdb] + +# Maximum mmap open files, this will affect the virtual memory used by +# the process +max-open-files = 1000 + +# LRU cache size, LRU is used by rocksdb to store contents of the +# uncompressed sstables. You can use `m` or `g` prefix for megabytes +# and gigabytes, respectively. +lru-cache-size = "200m" + +[storage.engines.hyperleveldb] + +# Maximum mmap open files, this will affect the virtual memory used by +# the process +max-open-files = 1000 + +# LRU cache size, LRU is used by rocksdb to store contents of the +# uncompressed sstables. You can use `m` or `g` prefix for megabytes +# and gigabytes, respectively. +lru-cache-size = "200m" + +[storage.engines.lmdb] + +map-size = "100g" + +[cluster] +# A comma separated list of servers to seed +# this server. this is only relevant when the +# server is joining a new cluster. Otherwise +# the server will use the list of known servers +# prior to shutting down. Any server can be pointed to +# as a seed. It will find the Raft leader automatically. + +# Here's an example. Note that the port on the host is the same as the raft port. +# seed-servers = ["hosta:8090","hostb:8090"] + +# Replication happens over a TCP connection with a Protobuf protocol. +# This port should be reachable between all servers in a cluster. +# However, this port shouldn't be accessible from the internet. + +protobuf_port = 8099 +protobuf_timeout = "2s" # the write timeout on the protobuf conn any duration parseable by time.ParseDuration +protobuf_heartbeat = "200ms" # the heartbeat interval between the servers. must be parseable by time.ParseDuration +protobuf_min_backoff = "1s" # the minimum backoff after a failed heartbeat attempt +protobuf_max_backoff = "10s" # the maxmimum backoff after a failed heartbeat attempt + +# How many write requests to potentially buffer in memory per server. If the buffer gets filled then writes +# will still be logged and once the server has caught up (or come back online) the writes +# will be replayed from the WAL +write-buffer-size = 1000 + +# the maximum number of responses to buffer from remote nodes, if the +# expected number of responses exceed this number then querying will +# happen sequentially and the buffer size will be limited to this +# number +max-response-buffer-size = 100 + +# When queries get distributed out to shards, they go in parallel. This means that results can get buffered +# in memory since results will come in any order, but have to be processed in the correct time order. +# Setting this higher will give better performance, but you'll need more memory. Setting this to 1 will ensure +# that you don't need to buffer in memory, but you won't get the best performance. +concurrent-shard-query-limit = 10 + +[wal] + +dir = "/opt/influxdb/shared/data/wal" +flush-after = 1000 # the number of writes after which wal will be flushed, 0 for flushing on every write +bookmark-after = 1000 # the number of writes after which a bookmark will be created + +# the number of writes after which an index entry is created pointing +# to the offset of the first request, default to 1k +index-after = 1000 + +# the number of requests per one log file, if new requests came in a +# new log file will be created +requests-per-logfile = 10000 diff --git a/src/InfluxDB/Adapter/ConnectableInterface.php b/src/InfluxDB/Adapter/ConnectableInterface.php deleted file mode 100644 index 1b7a79643..000000000 --- a/src/InfluxDB/Adapter/ConnectableInterface.php +++ /dev/null @@ -1,8 +0,0 @@ -options->getHttpSeriesEndpoint(); + try { return $this->httpClient->get($endpoint, $options)->json(); + } catch (\Exception $e) { + var_dump((string)$e->getResponse()->getBody(true)); + die(); + } } } diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index 2cb026ede..e2dcf8a51 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -3,35 +3,20 @@ namespace InfluxDB\Adapter; use InfluxDB\Options; -class UdpAdapter implements AdapterInterface, ConnectableInterface +class UdpAdapter implements AdapterInterface { private $options; - private $socket; public function __construct(Options $options) { $this->options = $options; } - public function getSocket() - { - return $this->socket; - } - - public function connect() - { - $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - return $this; - } - - public function disconnect() - { - socket_close($this->getSocket()); - } - public function send($message) { + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); $message = json_encode($message); - socket_sendto($this->getSocket(), $message, strlen($message), 0, $this->host, $this->port); + socket_sendto($socket, $message, strlen($message), 0, $this->options->getHost(), $this->options->getPort()); + socket_close($socket); } } diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 501afcefd..2b9017025 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -20,26 +20,6 @@ class Client return $this->adapter; } - public function connect() - { - $result = false; - if ($this->getAdapter() instanceOf ConnectableInterface) { - $result = $this->getAdapter()->connect(); - } - - return $result; - } - - public function disconnect() - { - $result = false; - if ($this->getAdapter() instanceOf ConnectableInterface) { - $result = $this->getAdapter()->disconnect(); - } - - return $result; - } - public function mark($name, array $values) { $data =[]; diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 566150f7d..e4d5b20a1 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -3,11 +3,13 @@ namespace InfluxDB; use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter; use InfluxDB\Options; +use InfluxDB\Adapter\UdpAdapter; use GuzzleHttp\Client as GuzzleHttpClient; use crodas\InfluxPHP\Client as Crodas; class ClientTest extends \PHPUnit_Framework_TestCase { + private $rawOptions; private $object; private $options; @@ -16,6 +18,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase public function setUp() { $options = include __DIR__ . '/../bootstrap.php'; + $this->rawOptions = $options; $client = new Crodas( $options["tcp"]["host"], @@ -30,6 +33,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase } $client->createDatabase($options["tcp"]["database"]); + try { + $client->deleteDatabase($options["udp"]["database"]); + } catch (\Exception $e) { + // nothing... + } + $client->createDatabase($options["udp"]["database"]); + $this->anotherClient = $client; $tcpOptions = $options["tcp"]; @@ -51,6 +61,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->object = $influx; } + /** + * @group tcp + */ public function testGuzzleHttpApiWorksCorrectly() { $this->object->mark("tcp.test", ["mark" => "element"]); @@ -60,6 +73,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body[0]["points"][0][2]); } + /** + * @group tcp + */ public function testGuzzleHttpQueryApiWorksCorrectly() { $this->object->mark("tcp.test", ["mark" => "element"]); @@ -71,6 +87,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body[0]["points"][0][2]); } + /** + * @group tcp + */ public function testGuzzleHttpQueryApiWithMultipleData() { $this->object->mark("tcp.test", ["mark" => "element"]); @@ -83,6 +102,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("tcp.test", $body[0]["name"]); } + /** + * @group tcp + */ public function testGuzzleHttpQueryApiWithTimePrecision() { $this->object->mark("tcp.test", ["mark" => "element"]); @@ -92,4 +114,33 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertCount(1, $body[0]["points"]); $this->assertEquals("tcp.test", $body[0]["name"]); } + + /** + * @group udp + */ + public function testUdpIpWriteData() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setUsername($rawOptions["udp"]["username"]); + $options->setPassword($rawOptions["udp"]["password"]); + $options->setPort($rawOptions["udp"]["port"]); + + $adapter = new UdpAdapter($options); + $object = new Client(); + $object->setAdapter($adapter); + + $object->mark("udp.test", ["mark" => "element"]); + $object->mark("udp.test", ["mark" => "element1"]); + $object->mark("udp.test", ["mark" => "element2"]); + $object->mark("udp.test", ["mark" => "element3"]); + + // Wait UDP/IP message arrives + usleep(200e3); + + $body = $this->object->query("select * from udp.test"); + + $this->assertCount(4, $body[0]["points"]); + $this->assertEquals("udp.test", $body[0]["name"]); + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index cf38911f3..9dd58c2cc 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,5 +7,12 @@ return [ "database" => "mine", "username" => "root", "password" => "root", - ] + ], + "udp" => [ + "host" => "localhost", + "port" => 5551, + "database" => "mine", + "username" => "root", + "password" => "root" + ], ]; From 5a00852f7361d7497f64cf3a76d98a6ef1f0011a Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 00:14:05 +0200 Subject: [PATCH 018/158] Removed Udp spec for connectable --- spec/InfluxDB/Adapter/UdpAdapterSpec.php | 1 - spec/InfluxDB/ClientSpec.php | 22 ---------------------- 2 files changed, 23 deletions(-) diff --git a/spec/InfluxDB/Adapter/UdpAdapterSpec.php b/spec/InfluxDB/Adapter/UdpAdapterSpec.php index 5d1aefc6a..48e14198f 100644 --- a/spec/InfluxDB/Adapter/UdpAdapterSpec.php +++ b/spec/InfluxDB/Adapter/UdpAdapterSpec.php @@ -21,6 +21,5 @@ class UdpAdapterSpec extends ObjectBehavior function it_should_implement_adapter_interface() { $this->shouldImplement("InfluxDB\Adapter\AdapterInterface"); - $this->shouldImplement("InfluxDB\Adapter\ConnectableInterface"); } } diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index 888f21b8c..a0ee5ae02 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -20,28 +20,6 @@ class ClientSpec extends ObjectBehavior $this->shouldHaveType('InfluxDB\Client'); } - function it_should_be_connectable(ConnectableInterface $adapter) - { - $adapter->connect()->willReturn(true)->shouldBeCalledTimes(1); - - $this->setAdapter($adapter); - $this->connect()->shouldReturn(true); - } - - function it_should_be_disconnectable(ConnectableInterface $adapter) - { - $adapter->disconnect()->willReturn(true)->shouldBeCalledTimes(1); - - $this->setAdapter($adapter); - $this->disconnect()->shouldReturn(true); - } - - function it_should_not_call_connect(AdapterInterface $adapter) - { - $this->setAdapter($adapter); - $this->connect()->shouldReturn(false); - } - function it_should_send_data(AdapterInterface $adapter) { $adapter->send([[ From e9a487ae2afac2ecb611072ab6eefe4a1c42a6e6 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 00:18:21 +0200 Subject: [PATCH 019/158] set phpspec in non-interactive mode --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bc5c8ba79..38ea92490 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,5 +19,5 @@ before_script: - composer install --prefer-source script: - - vendor/bin/phpspec run + - vendor/bin/phpspec run -n - vendor/bin/phpunit From b5cb30a50d07a082533753840441d00452bbbced Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 08:19:51 +0200 Subject: [PATCH 020/158] Added database management for HTTP client --- scripts/influxdb_conf.toml | 2 +- spec/InfluxDB/Adapter/GuzzleAdapterSpec.php | 26 +++++++++++ src/InfluxDB/Adapter/GuzzleAdapter.php | 38 +++++++++++++--- src/InfluxDB/Adapter/QueryableInterface.php | 3 ++ src/InfluxDB/Adapter/UdpAdapter.php | 2 +- src/InfluxDB/Client.php | 24 ++++++++++ src/InfluxDB/Options.php | 16 +++++++ tests/InfluxDB/ClientTest.php | 50 +++++++++++---------- tests/bootstrap.php | 4 +- 9 files changed, 133 insertions(+), 32 deletions(-) diff --git a/scripts/influxdb_conf.toml b/scripts/influxdb_conf.toml index e0c505a7b..4c946e0b3 100644 --- a/scripts/influxdb_conf.toml +++ b/scripts/influxdb_conf.toml @@ -57,7 +57,7 @@ read-timeout = "5s" [[input_plugins.udp_servers]] # array of tables enabled = true port = 5551 - database = "mine" + database = "udp.test" # Raft configuration [raft] diff --git a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php index 5c61ce1bb..815fa87a7 100644 --- a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php +++ b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php @@ -13,6 +13,7 @@ class GuzzleAdapterSpec extends ObjectBehavior function let(Client $client, Options $options) { $options->getHttpSeriesEndpoint()->willReturn("localhost"); + $options->getHttpDatabaseEndpoint()->willReturn("localhost"); $options->getUsername()->willReturn("one"); $options->getPassword()->willReturn("two"); $this->beConstructedWith($client, $options); @@ -61,4 +62,29 @@ class GuzzleAdapterSpec extends ObjectBehavior )->willReturn(new Response(200, [], null)); $this->query("select * from tcp.test", "s")->shouldReturn(null); } + + function it_should_list_all_databases(Client $client, Options $options) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"] + ] + )->shouldBeCalledTimes(1)->willReturn(new Response(200, [], null)); + + $this->getDatabases()->shouldReturn(null); + } + + function it_should_create_a_new_database(Client $client, Options $options) + { + $client->post( + "localhost", + [ + "auth" => ["one", "two"], + "body" => json_encode(["name" => "db_name"]) + ] + )->shouldBeCalledTimes(1)->willReturn(new Response(200, [], null)); + + $this->createDatabase("db_name")->shouldReturn(null); + } } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index bd715057b..45ad43ea3 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -42,11 +42,39 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface } $endpoint = $this->options->getHttpSeriesEndpoint(); - try { + return $this->httpClient->get($endpoint, $options)->json(); - } catch (\Exception $e) { - var_dump((string)$e->getResponse()->getBody(true)); - die(); - } + } + + public function getDatabases() + { + $options = [ + "auth" => [$this->options->getUsername(), $this->options->getPassword()], + ]; + + $endpoint = $this->options->getHttpDatabaseEndpoint(); + + return $this->httpClient->get($endpoint, $options)->json(); + } + + public function createDatabase($name) + { + $httpMessage = [ + "auth" => [$this->options->getUsername(), $this->options->getPassword()], + "body" => json_encode(["name" => $name]) + ]; + + $endpoint = $this->options->getHttpDatabaseEndpoint(); + return $this->httpClient->post($endpoint, $httpMessage)->json(); + } + + public function deleteDatabase($name) + { + $httpMessage = [ + "auth" => [$this->options->getUsername(), $this->options->getPassword()], + ]; + + $endpoint = $this->options->getHttpDatabaseEndpoint($name); + return $this->httpClient->delete($endpoint, $httpMessage)->json(); } } diff --git a/src/InfluxDB/Adapter/QueryableInterface.php b/src/InfluxDB/Adapter/QueryableInterface.php index fa604b069..164f30bf4 100644 --- a/src/InfluxDB/Adapter/QueryableInterface.php +++ b/src/InfluxDB/Adapter/QueryableInterface.php @@ -4,4 +4,7 @@ namespace InfluxDb\Adapter; interface QueryableInterface { public function query($query, $timePrecision = false); + public function getDatabases(); + public function createDatabase($name); + public function deleteDatabase($name); } diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index e2dcf8a51..88827173f 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -14,8 +14,8 @@ class UdpAdapter implements AdapterInterface public function send($message) { - $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); $message = json_encode($message); + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_sendto($socket, $message, strlen($message), 0, $this->options->getHost(), $this->options->getPort()); socket_close($socket); } diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 2b9017025..6971d71ba 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -41,6 +41,30 @@ class Client return $this->getAdapter()->query($query, $timePrecision); } + public function getDatabases() + { + if (!($this->getAdapter() instanceOf QueryableInterface)) { + throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); + } + return $this->getAdapter()->getDatabases(); + } + + public function createDatabase($name) + { + if (!($this->getAdapter() instanceOf QueryableInterface)) { + throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); + } + return $this->getAdapter()->createDatabase($name); + } + + public function deleteDatabase($name) + { + if (!($this->getAdapter() instanceOf QueryableInterface)) { + throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); + } + return $this->getAdapter()->deleteDatabase($name); + } + private function clearTimePrecision($timePrecision) { switch ($timePrecision) { diff --git a/src/InfluxDB/Options.php b/src/InfluxDB/Options.php index 02ff5ef44..a9478ba44 100644 --- a/src/InfluxDB/Options.php +++ b/src/InfluxDB/Options.php @@ -97,4 +97,20 @@ class Options $this->getDatabase() ); } + + public function getHttpDatabaseEndpoint($name = false) + { + $url = sprintf( + "%s://%s:%d/db", + $this->getProtocol(), + $this->getHost(), + $this->getPort() + ); + + if ($name !== false) { + $url .= "/{$name}"; + } + + return $url; + } } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index e4d5b20a1..5d0dc8af1 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -5,7 +5,6 @@ use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter; use InfluxDB\Options; use InfluxDB\Adapter\UdpAdapter; use GuzzleHttp\Client as GuzzleHttpClient; -use crodas\InfluxPHP\Client as Crodas; class ClientTest extends \PHPUnit_Framework_TestCase { @@ -20,28 +19,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options = include __DIR__ . '/../bootstrap.php'; $this->rawOptions = $options; - $client = new Crodas( - $options["tcp"]["host"], - $options["tcp"]["port"], - $options["tcp"]["username"], - $options["tcp"]["password"] - ); - try { - $client->deleteDatabase($options["tcp"]["database"]); - } catch (\Exception $e) { - // nothing... - } - $client->createDatabase($options["tcp"]["database"]); - - try { - $client->deleteDatabase($options["udp"]["database"]); - } catch (\Exception $e) { - // nothing... - } - $client->createDatabase($options["udp"]["database"]); - - $this->anotherClient = $client; - $tcpOptions = $options["tcp"]; $options = new Options(); @@ -59,6 +36,14 @@ class ClientTest extends \PHPUnit_Framework_TestCase $influx = new Client(); $influx->setAdapter($adapter); $this->object = $influx; + + $databases = $this->object->getDatabases(); + foreach ($databases as $database) { + $this->object->deleteDatabase($database["name"]); + } + + $this->object->createDatabase($this->rawOptions["udp"]["database"]); + $this->object->createDatabase($this->rawOptions["tcp"]["database"]); } /** @@ -122,6 +107,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase { $rawOptions = $this->rawOptions; $options = new Options(); + $options->setHost($rawOptions["udp"]["host"]); $options->setUsername($rawOptions["udp"]["username"]); $options->setPassword($rawOptions["udp"]["password"]); $options->setPort($rawOptions["udp"]["port"]); @@ -138,9 +124,27 @@ class ClientTest extends \PHPUnit_Framework_TestCase // Wait UDP/IP message arrives usleep(200e3); + $this->options->setDatabase("udp.test"); $body = $this->object->query("select * from udp.test"); $this->assertCount(4, $body[0]["points"]); $this->assertEquals("udp.test", $body[0]["name"]); } + + public function testListActiveDatabses() + { + $databases = $this->object->getDatabases(); + + $this->assertCount(2, $databases); + } + + public function testCreateANewDatabase() + { + $this->object->createDatabase("walter"); + $databases = $this->object->getDatabases(); + + $this->assertCount(3, $databases); + + $this->object->deleteDatabase("walter"); + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9dd58c2cc..99b776def 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,14 +4,14 @@ return [ "host" => "localhost", "port" => 8086, "protocol" => "http", - "database" => "mine", + "database" => "tcp.test", "username" => "root", "password" => "root", ], "udp" => [ "host" => "localhost", "port" => 5551, - "database" => "mine", + "database" => "udp.test", "username" => "root", "password" => "root" ], From 930593811bd7aa5004b5f4b104a394ad243df554 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 08:22:28 +0200 Subject: [PATCH 021/158] Removed old dependencies --- composer.json | 4 +-- composer.lock | 91 +++------------------------------------------------ 2 files changed, 5 insertions(+), 90 deletions(-) diff --git a/composer.json b/composer.json index e6b7245c2..ea532ed47 100644 --- a/composer.json +++ b/composer.json @@ -7,9 +7,7 @@ }, "require-dev": { "phpspec/phpspec": "2.*", - "phpunit/phpunit": "4.*", - "zendframework/zend-stdlib": "~2", - "crodas/influx-php": "dev-master" + "phpunit/phpunit": "4.*" }, "homepage": "http://www.corley.it/", "keywords": ["influxdb", "udp", "sdk"], diff --git a/composer.lock b/composer.lock index 98d05b929..18269867e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "1b622dda38682502a547657384b6fe7f", + "hash": "17fa2295e2cd007935278098484ab7cc", "packages": [ { "name": "guzzlehttp/guzzle", @@ -126,39 +126,6 @@ } ], "packages-dev": [ - { - "name": "crodas/influx-php", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/crodas/InfluxPHP.git", - "reference": "205bd51cb44dec70d0da06ba87e47f5c0986bdb4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/crodas/InfluxPHP/zipball/205bd51cb44dec70d0da06ba87e47f5c0986bdb4", - "reference": "205bd51cb44dec70d0da06ba87e47f5c0986bdb4", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "lib/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "authors": [ - { - "name": "César D. Rodas", - "email": "crodas@php.net" - } - ], - "description": "Simple client for InfluxDB", - "time": "2014-09-04 17:26:53" - }, { "name": "ocramius/instantiator", "version": "1.1.3", @@ -1335,65 +1302,15 @@ "description": "Symfony Yaml Component", "homepage": "http://symfony.com", "time": "2014-08-31 03:22:04" - }, - { - "name": "zendframework/zend-stdlib", - "version": "2.3.1", - "target-dir": "Zend/Stdlib", - "source": { - "type": "git", - "url": "https://github.com/zendframework/Component_ZendStdlib.git", - "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/c1f4830018b5d4f034d32fa01a9e17ea176f56f6", - "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6", - "shasum": "" - }, - "require": { - "php": ">=5.3.23" - }, - "require-dev": { - "zendframework/zend-eventmanager": "self.version", - "zendframework/zend-serializer": "self.version", - "zendframework/zend-servicemanager": "self.version" - }, - "suggest": { - "zendframework/zend-eventmanager": "To support aggregate hydrator usage", - "zendframework/zend-serializer": "Zend\\Serializer component", - "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" - } - }, - "autoload": { - "psr-0": { - "Zend\\Stdlib\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "keywords": [ - "stdlib", - "zf2" - ], - "time": "2014-04-15 15:28:48" } ], "aliases": [ ], "minimum-stability": "stable", - "stability-flags": { - "crodas/influx-php": 20 - }, + "stability-flags": [ + + ], "prefer-stable": false, "platform": [ From 0244b151c08d76776eda5f3050f7d20889bd0b72 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 08:40:30 +0200 Subject: [PATCH 022/158] Updated docs --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6fc9ea862..5fbc30cb3 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,12 @@ $client->setAdapter($adapter); Actually Guzzle is used as HTTP client library -``` +```php +setAdapter($adapter); From 14231410bccf4474023438ab05c067b81dd202d2 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 08:45:11 +0200 Subject: [PATCH 023/158] Bumped version 0.1.0 --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..6e8bf73aa --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 From cc56f6449d006544a7ee0b76ad666e60b75a4955 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 09:17:34 +0200 Subject: [PATCH 024/158] Fixes #1 - Send data with time_precision --- spec/InfluxDB/ClientSpec.php | 19 ++++++++++++++++++- src/InfluxDB/Adapter/AdapterInterface.php | 2 +- src/InfluxDB/Adapter/GuzzleAdapter.php | 6 +++++- src/InfluxDB/Adapter/UdpAdapter.php | 5 ++++- src/InfluxDB/Client.php | 7 +++++-- tests/InfluxDB/ClientTest.php | 15 +++++++++++++++ 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index a0ee5ae02..b1ff81cb6 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -28,7 +28,7 @@ class ClientSpec extends ObjectBehavior "points" => [ ["Guccini", "Autogrill"] ] - ]])->shouldBeCalledTimes(1); + ]], false)->shouldBeCalledTimes(1); $this->mark("video.search", [ "author" => "Guccini", @@ -36,6 +36,23 @@ class ClientSpec extends ObjectBehavior ]); } + function it_should_send_data_with_time_precision(AdapterInterface $adapter) + { + $adapter->send([[ + "name" => "video.search", + "columns" => ["time", "author", "title"], + "points" => [ + ["1410591552", "Guccini", "Autogrill"] + ] + ]], "s")->shouldBeCalledTimes(1); + + $this->mark("video.search", [ + "time" => "1410591552", + "author" => "Guccini", + "title" => "Autogrill" + ], "s"); + } + function it_should_query_on_querable_adapter(GuzzleAdapter $adapter) { $this->setAdapter($adapter); diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php index d0b9e539a..79ed18670 100644 --- a/src/InfluxDB/Adapter/AdapterInterface.php +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -3,5 +3,5 @@ namespace InfluxDB\Adapter; interface AdapterInterface { - public function send($message); + public function send($message, $timePrecision = false); } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 45ad43ea3..96a109a4a 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -17,13 +17,17 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface $this->options = $options; } - public function send($message) + public function send($message, $timePrecision = false) { $httpMessage = [ "auth" => [$this->options->getUsername(), $this->options->getPassword()], "body" => json_encode($message) ]; + if ($timePrecision) { + $httpMessage["query"]["time_precision"] = $timePrecision; + } + $endpoint = $this->options->getHttpSeriesEndpoint(); return $this->httpClient->post($endpoint, $httpMessage); } diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index 88827173f..4cc08c775 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -12,7 +12,10 @@ class UdpAdapter implements AdapterInterface $this->options = $options; } - public function send($message) + /** + * @todo Handle timePrecision parameter + */ + public function send($message, $timePrecision = false) { $message = json_encode($message); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 6971d71ba..3b4c7e95c 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -20,14 +20,17 @@ class Client return $this->adapter; } - public function mark($name, array $values) + public function mark($name, array $values, $timePrecision = false) { $data =[]; + + $timePrecision = $this->clearTimePrecision($timePrecision); + $data['name'] = $name; $data['columns'] = array_keys($values); $data['points'][] = array_values($values); - return $this->getAdapter()->send([$data]); + return $this->getAdapter()->send([$data], $timePrecision); } public function query($query, $timePrecision = false) diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 5d0dc8af1..45ea0397e 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -100,6 +100,21 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("tcp.test", $body[0]["name"]); } + /** + * @group tcp + */ + public function testGuzzleHttpWriteApiWithTimePrecision() + { + $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); + + $body = $this->object->query("select mark from tcp.test", "ms"); + + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + + $this->assertEquals("1410591552000", $body[0]["points"][0][0]); + } + /** * @group udp */ From e99204088083b369fc5e680b3653b14fef23e7da Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 09:22:14 +0200 Subject: [PATCH 025/158] Updated docs (time precision) --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 5fbc30cb3..17aace4d6 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,18 @@ $client = new Client(); $client->setAdapter($adapter); ``` +### Time Precision write/read queries + +You can set the `time_precision` for query query + +```php +$client->mark("app.search", $points, "s"); //points contains "time" that is in seconds +``` + +```php +$client->query("select * from app.search", "s"); // retrieve points using seconds for time column +``` + ### Query InfluxDB You can query the time series database using the query method. From 05163905ebe7558642158997b74941658bcd2153 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 09:23:29 +0200 Subject: [PATCH 026/158] Bumped version 0.1.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6e8bf73aa..17e51c385 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0 +0.1.1 From c682d8fe708de98691bc00534f29cc1209ad9a4d Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 09:36:16 +0200 Subject: [PATCH 027/158] Added docs for handle databases --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 17aace4d6..59068ea0c 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,18 @@ array(1) { } ``` +## Database operations + +You can create, list or destroy databases using dedicated methods + +```php +$client->getDatabases(); // list all databases +$client->createDatabase("my.name"); // create a new database with name "my.name" +$client->deleteDatabase("my.name"); // delete an existing database with name "my.name" +``` + +Actually only queryable adapters can handle databases (implements the `QueryableInterface`) + ## Install it Just use composer From baedecd88e1bbf2e0d36a0f4fdca8ddac4a861b8 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 09:48:37 +0200 Subject: [PATCH 028/158] Run tests also against PHP 5.4 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 38ea92490..f48187f5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php php: + - 5.4 - 5.5 - 5.6 From 88c00c3b02cbfe33a07cff79800df25733851866 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 11:36:17 +0200 Subject: [PATCH 029/158] Fixes #2 - Added factory method In order to obtain a valid client you can use the factory --- composer.json | 5 +- composer.lock | 151 ++++++++++++++++++++++++- src/InfluxDB/Adapter/GuzzleAdapter.php | 5 + src/InfluxDB/Adapter/UdpAdapter.php | 5 + src/InfluxDB/ClientFactory.php | 47 ++++++++ tests/InfluxDB/ClientFactoryTest.php | 57 ++++++++++ 6 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 src/InfluxDB/ClientFactory.php create mode 100644 tests/InfluxDB/ClientFactoryTest.php diff --git a/composer.json b/composer.json index ea532ed47..83bc0818c 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,10 @@ "license": "MIT", "description": "Send your app metrics to InfluxDB", "require": { - "guzzlehttp/guzzle": "~4" + "guzzlehttp/guzzle": "~4", + "zendframework/zend-stdlib": "~2", + "zendframework/zend-filter": "~2", + "zendframework/zend-servicemanager": "~2" }, "require-dev": { "phpspec/phpspec": "2.*", diff --git a/composer.lock b/composer.lock index 18269867e..6fda5d2a8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "17fa2295e2cd007935278098484ab7cc", + "hash": "5647460e792745752274202f2289a0cc", "packages": [ { "name": "guzzlehttp/guzzle", @@ -123,6 +123,155 @@ "stream" ], "time": "2014-08-17 21:15:53" + }, + { + "name": "zendframework/zend-filter", + "version": "2.3.1", + "target-dir": "Zend/Filter", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendFilter.git", + "reference": "1889b7aa499beccadac770780a73e1a40e0f8a53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/1889b7aa499beccadac770780a73e1a40e0f8a53", + "reference": "1889b7aa499beccadac770780a73e1a40e0f8a53", + "shasum": "" + }, + "require": { + "php": ">=5.3.23", + "zendframework/zend-stdlib": "self.version" + }, + "require-dev": { + "zendframework/zend-crypt": "self.version", + "zendframework/zend-servicemanager": "self.version", + "zendframework/zend-uri": "self.version" + }, + "suggest": { + "zendframework/zend-crypt": "Zend\\Crypt component", + "zendframework/zend-i18n": "Zend\\I18n component", + "zendframework/zend-servicemanager": "Zend\\ServiceManager component", + "zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Filter\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides a set of commonly needed data filters", + "keywords": [ + "filter", + "zf2" + ], + "time": "2014-04-15 15:28:47" + }, + { + "name": "zendframework/zend-servicemanager", + "version": "2.3.1", + "target-dir": "Zend/ServiceManager", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendServiceManager.git", + "reference": "652ab6e142b7afd1eede8f0f33b47d2599786c84" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/652ab6e142b7afd1eede8f0f33b47d2599786c84", + "reference": "652ab6e142b7afd1eede8f0f33b47d2599786c84", + "shasum": "" + }, + "require": { + "php": ">=5.3.23" + }, + "require-dev": { + "zendframework/zend-di": "self.version" + }, + "suggest": { + "zendframework/zend-di": "Zend\\Di component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\ServiceManager\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "servicemanager", + "zf2" + ], + "time": "2014-04-15 15:28:43" + }, + { + "name": "zendframework/zend-stdlib", + "version": "2.3.1", + "target-dir": "Zend/Stdlib", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendStdlib.git", + "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/c1f4830018b5d4f034d32fa01a9e17ea176f56f6", + "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6", + "shasum": "" + }, + "require": { + "php": ">=5.3.23" + }, + "require-dev": { + "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-serializer": "self.version", + "zendframework/zend-servicemanager": "self.version" + }, + "suggest": { + "zendframework/zend-eventmanager": "To support aggregate hydrator usage", + "zendframework/zend-serializer": "Zend\\Serializer component", + "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Stdlib\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "keywords": [ + "stdlib", + "zf2" + ], + "time": "2014-04-15 15:28:48" } ], "packages-dev": [ diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 96a109a4a..1fa1d35ea 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -17,6 +17,11 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface $this->options = $options; } + public function getOptions() + { + return $this->options; + } + public function send($message, $timePrecision = false) { $httpMessage = [ diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index 4cc08c775..ea831745c 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -12,6 +12,11 @@ class UdpAdapter implements AdapterInterface $this->options = $options; } + public function getOptions() + { + return $this->options; + } + /** * @todo Handle timePrecision parameter */ diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php new file mode 100644 index 000000000..1fe7846d1 --- /dev/null +++ b/src/InfluxDB/ClientFactory.php @@ -0,0 +1,47 @@ + [ + "name" => false, + "options" => [], + ], + "options" => [], + ]; + + public static function create(array $options) + { + $options = array_replace_recursive(self::$options, $options); + + $adapterName = $options["adapter"]["name"]; + if (!class_exists($adapterName)) { + throw new \InvalidArgumentException("Missing class: {$adapterName}"); + } + $adapterOptions = new Options(); + + $hydrator = new ClassMethods(); + $hydrator->hydrate($options["options"], $adapterOptions); + + $adapter = null; + switch ($adapterName) { + case 'InfluxDB\\Adapter\\UdpAdapter': + $adapter = new $adapterName($adapterOptions); + break; + case 'InfluxDB\\Adapter\\GuzzleAdapter': + $adapter = new $adapterName(new GuzzleClient($options["adapter"]["options"]), $adapterOptions); + break; + default: + throw new \InvalidArgumentException("Missing adapter {$adapter}"); + } + + $client = new Client(); + $client->setAdapter($adapter); + + return $client; + } +} diff --git a/tests/InfluxDB/ClientFactoryTest.php b/tests/InfluxDB/ClientFactoryTest.php new file mode 100644 index 000000000..febd80294 --- /dev/null +++ b/tests/InfluxDB/ClientFactoryTest.php @@ -0,0 +1,57 @@ + [ + "name" => "InfluxDB\\Adapter\\UdpAdapter", + ], + "options" => [ + "host" => "127.0.0.1", + "username" => "user", + "password" => "pass", + ], + ]; + + $client = ClientFactory::create($options); + $this->assertInstanceOf("InfluxDB\\Client", $client); + + $this->assertInstanceOf("InfluxDB\\Adapter\\UdpAdapter", $client->getAdapter()); + $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); + $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); + $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); + } + + /** + * @group factory + * @group tcp + */ + public function testCreateTcpClient() + { + $options = [ + "adapter" => [ + "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + ], + "options" => [ + "host" => "127.0.0.1", + "username" => "user", + "password" => "pass", + ], + ]; + + $client = ClientFactory::create($options); + $this->assertInstanceOf("InfluxDB\\Client", $client); + + $this->assertInstanceOf("InfluxDB\\Adapter\\GuzzleAdapter", $client->getAdapter()); + $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); + $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); + $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); + } +} From 66c42acec7036492f7d19dd55d83e8d291de83b3 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 11:42:44 +0200 Subject: [PATCH 030/158] Updated docs with factory method --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 59068ea0c..2c19815cc 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,31 @@ $client = new Client(); $client->setAdapter($adapter); ``` +### Create your client with the factory method + +Effectively the client creation is not so simple, for that +reason you can you the factory method provided with the library. + +``` +$options = [ + "adapter" => [ + "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + "options" => [ + // guzzle options + ], + ], + "options" => [ + "host" => "my.influx.domain.tld", + ], +]; +$client = \InfluxDB\ClientFactory::create($options); + +$client->mark("error.404", ["page" => "/a-missing-page"]); +``` + +Of course you can always use the DiC or your service manager in +order to create a valid client instance. + ### Time Precision write/read queries You can set the `time_precision` for query query From 9999d80c0ac16d82358e2a51e6cd3a831c480796 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 11:44:06 +0200 Subject: [PATCH 031/158] Bumped version 0.1.2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 17e51c385..d917d3e26 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.1 +0.1.2 From 7f4f2b5f2cc3c382d121f461e06324fabb891fc3 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Sep 2014 11:47:21 +0200 Subject: [PATCH 032/158] Removed old docs and moved install procedures --- README.md | 69 ++++++++++++++++--------------------------------------- 1 file changed, 20 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 2c19815cc..2e83db0d5 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,25 @@ Send metrics to InfluxDB and query for any data. +## Install it + +Just use composer + +```shell +php composer.phar require corley/influxdb-sdk:dev-master +``` + +Or place it in your require section + +```json +{ + "require": { + // ... + "corley/influxdb-sdk": "dev-master" + } +} +``` + Add new points: ```php @@ -58,7 +77,7 @@ $client->setAdapter($adapter); Effectively the client creation is not so simple, for that reason you can you the factory method provided with the library. -``` +```php $options = [ "adapter" => [ "name" => "InfluxDB\\Adapter\\GuzzleAdapter", @@ -147,51 +166,3 @@ $client->deleteDatabase("my.name"); // delete an existing database with name "my Actually only queryable adapters can handle databases (implements the `QueryableInterface`) -## Install it - -Just use composer - -```shell -php composer.phar require corley/influxdb-sdk:dev-master -``` - -Or place it in your require section - -```json -{ - "require": { - // ... - "corley/influxdb-sdk": "dev-master" - } -} -``` - - -## Prepare lib dependencies - -Use your DiC or Service Locator in order to provide a configured client - -```php -setHost("analytics.mine.domain.tld"); -$options->setPort(8086); -$options->setUsername("root"); -$options->setPassword("root"); -$options->setDatabase("mine"); - -$guzzleHttp = new GuzzleHttpClient(); -$adapter = new InfluxHttpAdapter($guzzleHttp, $options); - -$influx = new Client(); -$influx->setAdapter($adapter); - -$influx->mark("tcp.test", ["mark" => "element"]); -``` - From f1e4e8e83a7624f06b06699d5f83190fbb3fb67b Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Sep 2014 17:36:29 +0200 Subject: [PATCH 033/158] Added base filter functionality --- spec/InfluxDB/ClientSpec.php | 14 ++++- .../Filter/ColumnsPointsFilterSpec.php | 58 +++++++++++++++++++ src/InfluxDB/Client.php | 22 ++++++- src/InfluxDB/Filter/ColumnsPointsFilter.php | 22 +++++++ src/InfluxDB/Filter/FilterInterface.php | 7 +++ 5 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php create mode 100644 src/InfluxDB/Filter/ColumnsPointsFilter.php create mode 100644 src/InfluxDB/Filter/FilterInterface.php diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index b1ff81cb6..8fc4a6827 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -6,7 +6,8 @@ use Prophecy\Argument; use InfluxDB\Adapter\GuzzleAdapter; use InfluxDB\Adapter\UdpAdapter; use InfluxDB\Adapter\AdapterInterface; -use InfluxDB\Adapter\ConnectableInterface; +use InfluxDB\Filter\FilterInterface; +use InfluxDb\Adapter\QueryableInterface; class ClientSpec extends ObjectBehavior { @@ -83,4 +84,15 @@ class ClientSpec extends ObjectBehavior $this->shouldThrow("\\BadMethodCallException")->duringQuery("select * from tcp.test"); } + + function it_should_filter_returned_data(FilterInterface $filter, QueryableInterface $adapter) + { + $filter->filter(Argument::Any())->shouldBeCalledTimes(1)->willReturn([]); + $adapter->query(Argument::Any(), Argument::Any())->willReturn([]); + + $this->setFilter($filter); + $this->setAdapter($adapter); + + $this->query("select * from tcp.test")->shouldReturn([]); + } } diff --git a/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php b/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php new file mode 100644 index 000000000..4e85f88fc --- /dev/null +++ b/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php @@ -0,0 +1,58 @@ +shouldHaveType('InfluxDB\Filter\ColumnsPointsFilter'); + } + + function it_is_a_valid_filter() + { + $this->shouldImplement("InfluxDb\\Filter\\FilterInterface"); + } + + function it_should_map_columns_with_points() + { + $response = json_decode('[{"name":"hd_used","columns":["time","sequence_number","value","host","mount","time_precision"],"points":[[1410591684,11820001,23.2,"serverA","/mnt","s"]]}]'); + + $this->filter($response)->shouldBeEqualTo([ + "hd_used" => [ + [ + "time" => 1410591684, + "sequence_number" => 11820001, + "value" => 23.2, + "host" => "serverA", + "mount" => "/mnt", + "time_precision" => "s", + ], + ], + ]); + } + + function it_should_map_also_a_series_list() + { + $response = json_decode('[{"name":"list_series_result","columns":["time","name"],"points":[[0,"hd_used"]]}]'); + + $this->filter($response)->shouldBeEqualTo([ + "list_series_result" => [ + [ + "time" => 0, + "name" => "hd_used", + ], + ], + ]); + } + + function it_should_reply_to_an_empty_set() + { + $response = json_decode('[]'); + + $this->filter($response)->shouldBeEqualTo([]); + } +} diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 3b4c7e95c..94e879f8f 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -3,11 +3,23 @@ namespace InfluxDB; use InfluxDb\Adapter\QueryableInterface; -use InfluxDb\Adapter\ConnectableInterface; +use InfluxDB\Filter\FilterInterface; class Client { private $adapter; + private $filter; + + public function setFilter(Filter\FilterInterface $filter) + { + $this->filter = $filter; + return $this; + } + + public function getFilter() + { + return $this->filter; + } public function setAdapter(Adapter\AdapterInterface $adapter) { @@ -41,7 +53,13 @@ class Client $timePrecision = $this->clearTimePrecision($timePrecision); - return $this->getAdapter()->query($query, $timePrecision); + $return = $this->getAdapter()->query($query, $timePrecision); + + if ($this->getFilter() instanceOf FilterInterface) { + $return = $this->getFilter()->filter($return); + } + + return $return; } public function getDatabases() diff --git a/src/InfluxDB/Filter/ColumnsPointsFilter.php b/src/InfluxDB/Filter/ColumnsPointsFilter.php new file mode 100644 index 000000000..b6e94dc07 --- /dev/null +++ b/src/InfluxDB/Filter/ColumnsPointsFilter.php @@ -0,0 +1,22 @@ +columns; + $response[$metric->name] = []; + + foreach ($metric->points as $point) { + $response[$metric->name][] = array_combine($columns, $point); + } + } + + return $response; + } +} diff --git a/src/InfluxDB/Filter/FilterInterface.php b/src/InfluxDB/Filter/FilterInterface.php new file mode 100644 index 000000000..01bb59fd8 --- /dev/null +++ b/src/InfluxDB/Filter/FilterInterface.php @@ -0,0 +1,7 @@ + Date: Sun, 14 Sep 2014 17:56:16 +0200 Subject: [PATCH 034/158] Updated docs with filters --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 2e83db0d5..6b85296e0 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,11 @@ $options = [ "options" => [ "host" => "my.influx.domain.tld", ], + "filters" => [ + "query" => [ + "name" => "InfluxDB\\Filter\\ColumnsPointsFilter" + ], + ], ]; $client = \InfluxDB\ClientFactory::create($options); @@ -154,6 +159,31 @@ array(1) { } ``` +By default data is returned as is. You can add filters in order to +change a response as you prefer, by default this library carries a +common filter that simplifies the response. + +``` +$client->setFilter(new ColumnsPointsFilter()); + +$data = $client->query("select * from hd_used"); +``` + +With the "ColumnsPointsFilter" you get a list of dictionaries, +something like: + +``` +[ + "serie_name" => [ + [ + "time" => 410545635590, + "sequence_number" => 390001, + "mark" => "element", + ], + ] +] +``` + ## Database operations You can create, list or destroy databases using dedicated methods From e0f70d0f3d6292ac53a4d24b7a9d44fab7cf9c25 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Sep 2014 18:01:04 +0200 Subject: [PATCH 035/158] More clear specification on filters --- spec/InfluxDB/ClientSpec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index 8fc4a6827..126ac4f05 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -87,8 +87,8 @@ class ClientSpec extends ObjectBehavior function it_should_filter_returned_data(FilterInterface $filter, QueryableInterface $adapter) { + $adapter->query(Argument::Any(), Argument::Any())->willReturn(null); $filter->filter(Argument::Any())->shouldBeCalledTimes(1)->willReturn([]); - $adapter->query(Argument::Any(), Argument::Any())->willReturn([]); $this->setFilter($filter); $this->setAdapter($adapter); From 89234de46cbdac0d68003a1df2209be427823aa2 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Sep 2014 18:04:58 +0200 Subject: [PATCH 036/158] Added filters on factory method --- src/InfluxDB/ClientFactory.php | 7 ++++++ tests/InfluxDB/ClientFactoryTest.php | 33 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php index 1fe7846d1..035b7f53d 100644 --- a/src/InfluxDB/ClientFactory.php +++ b/src/InfluxDB/ClientFactory.php @@ -12,6 +12,9 @@ abstract class ClientFactory "options" => [], ], "options" => [], + "filters" => [ + "query" => false + ], ]; public static function create(array $options) @@ -42,6 +45,10 @@ abstract class ClientFactory $client = new Client(); $client->setAdapter($adapter); + if ($options["filters"]["query"]) { + $client->setFilter(new $options["filters"]["query"]["name"]); + } + return $client; } } diff --git a/tests/InfluxDB/ClientFactoryTest.php b/tests/InfluxDB/ClientFactoryTest.php index febd80294..058de134b 100644 --- a/tests/InfluxDB/ClientFactoryTest.php +++ b/tests/InfluxDB/ClientFactoryTest.php @@ -54,4 +54,37 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); } + + /** + * @group factory + * @group filters + */ + public function testCreateTcpClientWithFilter() + { + $options = [ + "adapter" => [ + "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + ], + "options" => [ + "host" => "127.0.0.1", + "username" => "user", + "password" => "pass", + ], + "filters" => [ + "query" => [ + "name" => "InfluxDB\\Filter\\ColumnsPointsFilter", + ], + ], + ]; + + $client = ClientFactory::create($options); + $this->assertInstanceOf("InfluxDB\\Client", $client); + + $this->assertInstanceOf("InfluxDB\\Adapter\\GuzzleAdapter", $client->getAdapter()); + $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); + $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); + $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); + + $this->assertInstanceOf("InfluxDB\\Filter\\ColumnsPointsFilter", $client->getFilter()); + } } From 961bef879474105ca882293605f84d3b61199460 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Sep 2014 18:07:49 +0200 Subject: [PATCH 037/158] Bumped version 0.2.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d917d3e26..0ea3a944b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.2 +0.2.0 From d44f92ddde69ca4864bc3490ebdd3414cbfd4788 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 25 Sep 2014 23:36:49 +0200 Subject: [PATCH 038/158] Added benchmarks for filters and adapters --- README.md | 31 +++ .../Benchmarks/InfluxDB/AdapterEvent.php | 48 ++++ .../Benchmarks/InfluxDB/FilterEvent.php | 111 +++++++++ composer.json | 6 +- composer.lock | 233 +++++++++++++++++- 5 files changed, 426 insertions(+), 3 deletions(-) create mode 100644 benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php create mode 100644 benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php diff --git a/README.md b/README.md index 6b85296e0..ef2f4c2ea 100644 --- a/README.md +++ b/README.md @@ -196,3 +196,34 @@ $client->deleteDatabase("my.name"); // delete an existing database with name "my Actually only queryable adapters can handle databases (implements the `QueryableInterface`) +## Benchmark + +### Adapters + +The impact using UDP or HTTP adapters + +``` +Corley\Benchmarks\InfluxDB\AdapterEvent + Method Name Iterations Average Time Ops/second + ------------------------ ------------ -------------- ------------- + sendDataUsingHttpAdapter: [1,000 ] [0.0026700308323] [374.52751] + sendDataUsingUdpAdapter : [1,000 ] [0.0000436344147] [22,917.69026] +``` + + +### Filter + +Just what append when you apply the `ColumnsPointsFilter` + +``` +Corley\Benchmarks\InfluxDB\FilterEvent + Method Name Iterations Average Time Ops/second + ------------------------ ------------ -------------- ------------- + get10PointDirectData : [10,000 ] [0.0001383633137] [7,227.34931] + get10PointFilteredData : [10,000 ] [0.0001662570953] [6,014.78089] + get100PointDirectData : [1,000 ] [0.0002406690121] [4,155.08416] + get100PointFilteredData : [1,000 ] [0.0008374640942] [1,194.08104] + get1000PointDirectData : [100 ] [0.0011058974266] [904.24299] + get1000PointFilteredData: [100 ] [0.0074790692329] [133.70648] +``` + diff --git a/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php b/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php new file mode 100644 index 000000000..55b418358 --- /dev/null +++ b/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php @@ -0,0 +1,48 @@ +setUsername("root"); + $options->setPassword("root"); + $options->setDatabase("bench"); + $client->setAdapter( + new GuzzleAdapter(new HttpClient(), $options) + ); + $this->httpClient = $client; + + $client = new Client(); + $client->setAdapter(new UdpAdapter(new Options())); + $this->udpClient = $client; + } + + /** + * @iterations 1000 + */ + public function sendDataUsingHttpAdapter() + { + $this->httpClient->mark("metric.name", ["key" => "value"]); + } + + /** + * @iterations 1000 + */ + public function sendDataUsingUdpAdapter() + { + $this->udpClient->mark("metric.name", ["key" => "value"]); + } +} diff --git a/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php b/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php new file mode 100644 index 000000000..e12ebaf4d --- /dev/null +++ b/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php @@ -0,0 +1,111 @@ +testData = [ + (object)[ + "name" => "test", + "columns" => [ + "time", + "sequence_number", + "value", + ], + "points" => [ + ], + ] + ]; + + $prophet = new Prophet; + $adapter = $prophet->prophesize('InfluxDB\Adapter\GuzzleAdapter'); + $adapter->query(Argument::any(), Argument::Any())->willReturn($this->testData); + + $this->withFilter = new Client(); + $this->withFilter->setAdapter($adapter->reveal()); + $this->withFilter->setFilter(new ColumnsPointsFilter()); + + $this->withoutFilter = new Client(); + $this->withoutFilter->setAdapter($adapter->reveal()); + } + + /** + * @iterations 10000 + */ + public function get10PointDirectData() + { + for ($i=0; $i<10; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + + $this->withoutFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 10000 + */ + public function get10PointFilteredData() + { + for ($i=0; $i<10; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + $this->withFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 1000 + */ + public function get100PointDirectData() + { + for ($i=0; $i<100; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + + $this->withoutFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 1000 + */ + public function get100PointFilteredData() + { + for ($i=0; $i<100; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + $this->withFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 100 + */ + public function get1000PointDirectData() + { + for ($i=0; $i<1000; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + + $this->withoutFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 100 + */ + public function get1000PointFilteredData() + { + for ($i=0; $i<1000; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + $this->withFilter->query("THE QUERY", "s"); + } +} diff --git a/composer.json b/composer.json index 83bc0818c..29649d848 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ }, "require-dev": { "phpspec/phpspec": "2.*", - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "4.*", + "athletic/athletic": "~0.1" }, "homepage": "http://www.corley.it/", "keywords": ["influxdb", "udp", "sdk"], @@ -30,7 +31,8 @@ ], "autoload": { "psr-0": { - "InfluxDB\\": ["./src/", "./tests"] + "InfluxDB\\": ["./src/", "./tests"], + "Corley\\": ["./benchmarks/"] } }, "suggests": { diff --git a/composer.lock b/composer.lock index 6fda5d2a8..0cfbc69fa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "5647460e792745752274202f2289a0cc", + "hash": "fef5f885184ca64f876e4cba2d1de5c3", "packages": [ { "name": "guzzlehttp/guzzle", @@ -275,6 +275,151 @@ } ], "packages-dev": [ + { + "name": "athletic/athletic", + "version": "v0.1.8", + "source": { + "type": "git", + "url": "https://github.com/polyfractal/athletic.git", + "reference": "51fe4b6e5298dd8af187825a4e57745898e37f0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/polyfractal/athletic/zipball/51fe4b6e5298dd8af187825a4e57745898e37f0e", + "reference": "51fe4b6e5298dd8af187825a4e57745898e37f0e", + "shasum": "" + }, + "require": { + "nategood/commando": "0.2.1", + "php": ">=5.3.9", + "pimple/pimple": ">=1.0,<3.0", + "zeptech/annotations": "1.1.*" + }, + "require-dev": { + "mikey179/vfsstream": "1.2.*", + "mockery/mockery": "0.8.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "0.6.*" + }, + "bin": [ + "bin/athletic" + ], + "type": "library", + "autoload": { + "psr-0": { + "Athletic": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Zachary Tong" + } + ], + "description": "PHP Benchmarking Framework", + "keywords": [ + "benchmark", + "benchmarking", + "profiling" + ], + "time": "2014-06-03 18:32:22" + }, + { + "name": "kevinlebrun/colors.php", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/kevinlebrun/colors.php.git", + "reference": "b13d23b9365ece519abc0eaa77cd3061c5810d30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kevinlebrun/colors.php/zipball/b13d23b9365ece519abc0eaa77cd3061c5810d30", + "reference": "b13d23b9365ece519abc0eaa77cd3061c5810d30", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Colors": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Le Brun", + "email": "lebrun.k@gmail.com", + "homepage": "http://kevinlebrun.fr", + "role": "developer" + } + ], + "description": "Colors for PHP CLI scripts", + "homepage": "https://github.com/kevinlebrun/colors.php", + "keywords": [ + "cli", + "color", + "colors", + "console", + "shell" + ], + "time": "2012-03-25 18:18:10" + }, + { + "name": "nategood/commando", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/nategood/commando.git", + "reference": "b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nategood/commando/zipball/b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1", + "reference": "b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1", + "shasum": "" + }, + "require": { + "kevinlebrun/colors.php": "0.2.*", + "php": ">=5.3" + }, + "type": "library", + "autoload": { + "psr-0": { + "Commando": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nate Good", + "email": "me@nategood.com", + "homepage": "http://nategood.com" + } + ], + "description": "PHP CLI Commando Style", + "homepage": "http://github.com/nategood/commando", + "keywords": [ + "automation", + "cli", + "command", + "command line", + "command line interface", + "scripting" + ], + "time": "2012-10-07 15:35:37" + }, { "name": "ocramius/instantiator", "version": "1.1.3", @@ -978,6 +1123,52 @@ ], "time": "2014-09-06 17:32:37" }, + { + "name": "pimple/pimple", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Pimple.git", + "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Pimple/zipball/ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", + "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2014-07-24 07:10:08" + }, { "name": "sebastian/comparator", "version": "1.0.0", @@ -1451,6 +1642,46 @@ "description": "Symfony Yaml Component", "homepage": "http://symfony.com", "time": "2014-08-31 03:22:04" + }, + { + "name": "zeptech/annotations", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/pgraham/php-annotations.git", + "reference": "9cd042daa9ace184d04b49f0605edf73f19a9c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pgraham/php-annotations/zipball/9cd042daa9ace184d04b49f0605edf73f19a9c71", + "reference": "9cd042daa9ace184d04b49f0605edf73f19a9c71", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "zpt\\anno": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "authors": [ + { + "name": "Philip Graham", + "email": "philip@zeptech.ca" + } + ], + "description": "DOC Block annotation parsing for PHP", + "homepage": "https://github.com/pgraham/php-annotations", + "keywords": [ + "annotations" + ], + "time": "2013-05-29 02:35:23" } ], "aliases": [ From 18311b0782483aed6d52e8fd3a812e2f62963efc Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 25 Sep 2014 23:47:58 +0200 Subject: [PATCH 039/158] Bumped version 0.2.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0ea3a944b..0c62199f1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 +0.2.1 From e72cfca70931ffe3b2c0751f4e7f1b05222fc5d7 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Fri, 26 Sep 2014 12:43:21 +0200 Subject: [PATCH 040/158] Travis Slack integration --- .travis.yml | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index f48187f5e..6e669d0d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,23 @@ language: php - php: - - 5.4 - - 5.5 - - 5.6 - +- 5.4 +- 5.5 +- 5.6 before_install: - - sudo apt-get update - - sudo apt-get install libcurl4-openssl-dev libjson0-dev - - wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb - - sudo useradd influxdb - - sudo dpkg -i influxdb_latest_amd64.deb - - sudo cp ./scripts/influxdb_conf.toml /opt/influxdb/shared/config.toml - - travis_retry sudo service influxdb restart - - sudo service influxdb status - +- sudo apt-get update +- sudo apt-get install libcurl4-openssl-dev libjson0-dev +- wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb +- sudo useradd influxdb +- sudo dpkg -i influxdb_latest_amd64.deb +- sudo cp ./scripts/influxdb_conf.toml /opt/influxdb/shared/config.toml +- travis_retry sudo service influxdb restart +- sudo service influxdb status before_script: - - composer selfupdate - - composer install --prefer-source - +- composer selfupdate +- composer install --prefer-source script: - - vendor/bin/phpspec run -n - - vendor/bin/phpunit +- vendor/bin/phpspec run -n +- vendor/bin/phpunit +notifications: + slack: + secure: UN4V33CfLzEcb+5/LWcfcbwROZobbUawgFSiM3TzagBC+7w0DH2rK8DczxkUBs5rNAaYBj+DkxmmF9tiDb0BLB7Jezlq0vmrNBOhregLodOG44/bFwg58YOwTGxt/Iak38A+8VskGj0sSybNq4TB1/K0040wXS5bA+M/9NqyQeo= From 318ef04a347f362ee4e941ef01bfab2a39f4981f Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 26 Sep 2014 21:36:09 +0200 Subject: [PATCH 041/158] Fixes composer.json suggests --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 29649d848..9d09071c1 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "Corley\\": ["./benchmarks/"] } }, - "suggests": { + "suggest": { "fabpot/pimple": "Allows to prepare the client dependencies in order to require an initialized instance", "zendframework/zend-servicemanager": "Use a service locator in order to prepare a valid instance", "symfony/dependency-injection": "Prepare a valid instance via the symfony DiC" From edbd3e5e27206422c466a48571bd1b5e0d1e1b48 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 26 Sep 2014 21:37:29 +0200 Subject: [PATCH 042/158] No time precision in UDP/IP --- src/InfluxDB/Adapter/GuzzleAdapter.php | 2 ++ src/InfluxDB/Adapter/UdpAdapter.php | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 1fa1d35ea..8bf2aade1 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -4,6 +4,8 @@ namespace InfluxDB\Adapter; use GuzzleHttp\Client; use InfluxDB\Options; +use InfluxDb\Adapter\QueryableInterface; +use InfluxDB\Adapter\AdapterInterface; class GuzzleAdapter implements AdapterInterface, QueryableInterface { diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index ea831745c..4ea572546 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -17,9 +17,6 @@ class UdpAdapter implements AdapterInterface return $this->options; } - /** - * @todo Handle timePrecision parameter - */ public function send($message, $timePrecision = false) { $message = json_encode($message); From 2d0abf0d4b42ae418964823f3d34b6498ac6747d Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 26 Sep 2014 21:38:34 +0200 Subject: [PATCH 043/158] Fixes namespace on queryable interface --- src/InfluxDB/Adapter/QueryableInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InfluxDB/Adapter/QueryableInterface.php b/src/InfluxDB/Adapter/QueryableInterface.php index 164f30bf4..2e4754011 100644 --- a/src/InfluxDB/Adapter/QueryableInterface.php +++ b/src/InfluxDB/Adapter/QueryableInterface.php @@ -1,5 +1,5 @@ Date: Fri, 26 Sep 2014 21:40:08 +0200 Subject: [PATCH 044/158] Fixes unused property database --- src/InfluxDB/Adapter/GuzzleAdapter.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 8bf2aade1..72695edf4 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -1,17 +1,13 @@ Date: Fri, 26 Sep 2014 21:55:40 +0200 Subject: [PATCH 045/158] Updated composer dependencies --- composer.lock | 110 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 26 deletions(-) diff --git a/composer.lock b/composer.lock index 0cfbc69fa..486709c9f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "fef5f885184ca64f876e4cba2d1de5c3", + "hash": "ff63d84450d0ba675f2231b385344e9a", "packages": [ { "name": "guzzlehttp/guzzle", @@ -126,17 +126,17 @@ }, { "name": "zendframework/zend-filter", - "version": "2.3.1", + "version": "2.3.3", "target-dir": "Zend/Filter", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendFilter.git", - "reference": "1889b7aa499beccadac770780a73e1a40e0f8a53" + "reference": "98b8c2abfdc9009e4c0157e78c9f22bf2cebb693" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/1889b7aa499beccadac770780a73e1a40e0f8a53", - "reference": "1889b7aa499beccadac770780a73e1a40e0f8a53", + "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/98b8c2abfdc9009e4c0157e78c9f22bf2cebb693", + "reference": "98b8c2abfdc9009e4c0157e78c9f22bf2cebb693", "shasum": "" }, "require": { @@ -171,25 +171,26 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed data filters", + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "filter", "zf2" ], - "time": "2014-04-15 15:28:47" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-servicemanager", - "version": "2.3.1", + "version": "2.3.3", "target-dir": "Zend/ServiceManager", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendServiceManager.git", - "reference": "652ab6e142b7afd1eede8f0f33b47d2599786c84" + "reference": "559403e4fd10db2516641f20f129a568d7e6a993" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/652ab6e142b7afd1eede8f0f33b47d2599786c84", - "reference": "652ab6e142b7afd1eede8f0f33b47d2599786c84", + "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/559403e4fd10db2516641f20f129a568d7e6a993", + "reference": "559403e4fd10db2516641f20f129a568d7e6a993", "shasum": "" }, "require": { @@ -217,25 +218,26 @@ "license": [ "BSD-3-Clause" ], + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "servicemanager", "zf2" ], - "time": "2014-04-15 15:28:43" + "time": "2014-09-16 22:58:11" }, { "name": "zendframework/zend-stdlib", - "version": "2.3.1", + "version": "2.3.3", "target-dir": "Zend/Stdlib", "source": { "type": "git", "url": "https://github.com/zendframework/Component_ZendStdlib.git", - "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6" + "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/c1f4830018b5d4f034d32fa01a9e17ea176f56f6", - "reference": "c1f4830018b5d4f034d32fa01a9e17ea176f56f6", + "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", + "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", "shasum": "" }, "require": { @@ -267,11 +269,12 @@ "license": [ "BSD-3-Clause" ], + "homepage": "https://github.com/zendframework/zf2", "keywords": [ "stdlib", "zf2" ], - "time": "2014-04-15 15:28:48" + "time": "2014-09-16 22:58:11" } ], "packages-dev": [ @@ -327,6 +330,60 @@ ], "time": "2014-06-03 18:32:22" }, + { + "name": "doctrine/instantiator", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "26404e0c90565b614ee76b988b9bc8790d77f590" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/26404e0c90565b614ee76b988b9bc8790d77f590", + "reference": "26404e0c90565b614ee76b988b9bc8790d77f590", + "shasum": "" + }, + "require": { + "php": "~5.3" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-08-25 15:09:25" + }, { "name": "kevinlebrun/colors.php", "version": "0.2.0", @@ -691,19 +748,20 @@ }, { "name": "phpspec/prophecy", - "version": "v1.2.0", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "328484c88ed3cd7d1980b624bb98fa635f212ec9" + "reference": "ed9c0bcffe4639a5b0ff83e399eeb28e7fcc68f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/328484c88ed3cd7d1980b624bb98fa635f212ec9", - "reference": "328484c88ed3cd7d1980b624bb98fa635f212ec9", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/ed9c0bcffe4639a5b0ff83e399eeb28e7fcc68f0", + "reference": "ed9c0bcffe4639a5b0ff83e399eeb28e7fcc68f0", "shasum": "" }, "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", "phpdocumentor/reflection-docblock": "~2.0" }, "require-dev": { @@ -745,7 +803,7 @@ "spy", "stub" ], - "time": "2014-07-18 21:26:55" + "time": "2014-09-23 10:52:18" }, { "name": "phpunit/php-code-coverage", @@ -996,16 +1054,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.2.5", + "version": "4.2.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c3abe5953d1e60a0bf23012b1bc8c4d07f4832d7" + "reference": "c28a790620fe30b049bb693be1ef9cd4e0fe906c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c3abe5953d1e60a0bf23012b1bc8c4d07f4832d7", - "reference": "c3abe5953d1e60a0bf23012b1bc8c4d07f4832d7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c28a790620fe30b049bb693be1ef9cd4e0fe906c", + "reference": "c28a790620fe30b049bb693be1ef9cd4e0fe906c", "shasum": "" }, "require": { @@ -1066,7 +1124,7 @@ "testing", "xunit" ], - "time": "2014-09-06 18:38:27" + "time": "2014-09-14 09:31:24" }, { "name": "phpunit/phpunit-mock-objects", From d0966dd5a41e5b54e834994d58d2647c6a2cd1f9 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 26 Sep 2014 22:06:41 +0200 Subject: [PATCH 046/158] Moved default options for factory --- src/InfluxDB/ClientFactory.php | 24 +++++++++++------------ tests/InfluxDB/ClientFactoryTest.php | 29 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php index 035b7f53d..cd94929f6 100644 --- a/src/InfluxDB/ClientFactory.php +++ b/src/InfluxDB/ClientFactory.php @@ -6,20 +6,20 @@ use GuzzleHttp\Client as GuzzleClient; abstract class ClientFactory { - private static $options = [ - "adapter" => [ - "name" => false, - "options" => [], - ], - "options" => [], - "filters" => [ - "query" => false - ], - ]; - public static function create(array $options) { - $options = array_replace_recursive(self::$options, $options); + $defaultOptions = [ + "adapter" => [ + "name" => false, + "options" => [], + ], + "options" => [], + "filters" => [ + "query" => false + ], + ]; + + $options = array_replace_recursive($defaultOptions, $options); $adapterName = $options["adapter"]["name"]; if (!class_exists($adapterName)) { diff --git a/tests/InfluxDB/ClientFactoryTest.php b/tests/InfluxDB/ClientFactoryTest.php index 058de134b..ddaf37898 100644 --- a/tests/InfluxDB/ClientFactoryTest.php +++ b/tests/InfluxDB/ClientFactoryTest.php @@ -3,6 +3,35 @@ namespace InfluxDB; class ClientFactoryTest extends \PHPUnit_Framework_TestCase { + /** + * @group factory + * + * @expectedException InvalidArgumentException + */ + public function testEmptyOptions() + { + $client = ClientFactory::create([]); + } + + /** + * @group factory + */ + public function testDefaultParams() + { + $client = ClientFactory::create(["adapter" => ["name" => "InfluxDB\\Adapter\\GuzzleAdapter"]]); + + $this->assertNull($client->getFilter()); + } + + /** + * @group factory + * @expectedException InvalidArgumentException + */ + public function testInvalidAdapter() + { + $client = ClientFactory::create(["adapter" => ["name" => "UdpAdapter"]]); + } + /** * @group factory * @group udp From e96b8b571606bf698935d3de1a2b3f47431f0f80 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 26 Sep 2014 22:13:30 +0200 Subject: [PATCH 047/158] Fixes different little problems --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0c62199f1..ee1372d33 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.2.2 From da3cb0ad1691d3c73c757fd508cf5aecddd25181 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 26 Sep 2014 22:17:08 +0200 Subject: [PATCH 048/158] Added SensioLabs Insight --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ef2f4c2ea..43eaa0351 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # InfluxDB PHP SDK +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/699a9a78-39aa-41d0-bb60-41dbf0f1251d/big.png)](https://insight.sensiolabs.com/projects/699a9a78-39aa-41d0-bb60-41dbf0f1251d) + * [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) * [![Dependency Status](https://www.versioneye.com/user/projects/54104e789e1622492d000025/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54104e789e1622492d000025) From 3e29ff5738c77a40ff9413fa18b181d83136dd6a Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 27 Sep 2014 08:35:34 +0200 Subject: [PATCH 049/158] Updated docs --- README.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 43eaa0351..54370dcd9 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ $client = \InfluxDB\ClientFactory::create($options); $client->mark("error.404", ["page" => "/a-missing-page"]); ``` -Of course you can always use the DiC or your service manager in -order to create a valid client instance. +Of course you can always use the DiC or your service manager in order to create +a valid client instance. ### Time Precision write/read queries @@ -125,10 +125,11 @@ $influx->query("select * from mine"); $influx->query("select * from mine", "s"); // with time_precision ``` -You can query the database only if the adapter is queryable (implements `QueryableInterface`), -actually `GuzzleAdapter`. +You can query the database only if the adapter is queryable (implements +`QueryableInterface`), actually `GuzzleAdapter`. -The adapter returns the json decoded body of the InfluxDB response, something like: +The adapter returns the json decoded body of the InfluxDB response, something +like: ``` array(1) { @@ -161,9 +162,9 @@ array(1) { } ``` -By default data is returned as is. You can add filters in order to -change a response as you prefer, by default this library carries a -common filter that simplifies the response. +By default data is returned as is. You can add filters in order to change a +response as you prefer, by default this library carries a common filter that +simplifies the response. ``` $client->setFilter(new ColumnsPointsFilter()); @@ -171,8 +172,7 @@ $client->setFilter(new ColumnsPointsFilter()); $data = $client->query("select * from hd_used"); ``` -With the "ColumnsPointsFilter" you get a list of dictionaries, -something like: +With the "ColumnsPointsFilter" you get a list of dictionaries, something like: ``` [ @@ -196,9 +196,10 @@ $client->createDatabase("my.name"); // create a new database with name "my.name" $client->deleteDatabase("my.name"); // delete an existing database with name "my.name" ``` -Actually only queryable adapters can handle databases (implements the `QueryableInterface`) +Actually only queryable adapters can handle databases (implements the +`QueryableInterface`) -## Benchmark +## Benchmarks ### Adapters @@ -212,8 +213,7 @@ Corley\Benchmarks\InfluxDB\AdapterEvent sendDataUsingUdpAdapter : [1,000 ] [0.0000436344147] [22,917.69026] ``` - -### Filter +### Filters Just what append when you apply the `ColumnsPointsFilter` @@ -229,3 +229,6 @@ Corley\Benchmarks\InfluxDB\FilterEvent get1000PointFilteredData: [100 ] [0.0074790692329] [133.70648] ``` +in order to eliminate the http handshake and bandwidth overhead network +operations are completely skipped + From 2d724bf23f97e65763ff4d7792369d57007ff690 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 9 Oct 2014 22:27:27 +0200 Subject: [PATCH 050/158] Updated dependencies --- composer.lock | 295 +++++++++++++++----------------------------------- 1 file changed, 90 insertions(+), 205 deletions(-) diff --git a/composer.lock b/composer.lock index 486709c9f..5e318be9e 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "guzzlehttp/guzzle", - "version": "4.2.2", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "9c4fbbf6457768f5036fbd88f1229f3fca812a5d" + "reference": "66fd916e9f9130bc22c51450476823391cb2f67c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9c4fbbf6457768f5036fbd88f1229f3fca812a5d", - "reference": "9c4fbbf6457768f5036fbd88f1229f3fca812a5d", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd916e9f9130bc22c51450476823391cb2f67c", + "reference": "66fd916e9f9130bc22c51450476823391cb2f67c", "shasum": "" }, "require": { @@ -69,7 +69,7 @@ "rest", "web service" ], - "time": "2014-09-08 22:11:58" + "time": "2014-10-05 19:29:14" }, { "name": "guzzlehttp/streams", @@ -332,16 +332,16 @@ }, { "name": "doctrine/instantiator", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "26404e0c90565b614ee76b988b9bc8790d77f590" + "reference": "8806c41c178ad4a2e87294b851d730779555d252" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/26404e0c90565b614ee76b988b9bc8790d77f590", - "reference": "26404e0c90565b614ee76b988b9bc8790d77f590", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8806c41c178ad4a2e87294b851d730779555d252", + "reference": "8806c41c178ad4a2e87294b851d730779555d252", "shasum": "" }, "require": { @@ -382,7 +382,7 @@ "constructor", "instantiate" ], - "time": "2014-08-25 15:09:25" + "time": "2014-10-04 22:48:25" }, { "name": "kevinlebrun/colors.php", @@ -477,119 +477,6 @@ ], "time": "2012-10-07 15:35:37" }, - { - "name": "ocramius/instantiator", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/Instantiator.git", - "reference": "e24a12178906ff2e7471b8aaf3a0eb789b59f881" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/Instantiator/zipball/e24a12178906ff2e7471b8aaf3a0eb789b59f881", - "reference": "e24a12178906ff2e7471b8aaf3a0eb789b59f881", - "shasum": "" - }, - "require": { - "ocramius/lazy-map": "1.0.*", - "php": "~5.3" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "2.0.*@ALPHA" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Instantiator\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/Ocramius/Instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2014-08-25 14:48:16" - }, - { - "name": "ocramius/lazy-map", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/LazyMap.git", - "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/LazyMap/zipball/7fe3d347f5e618bcea7d39345ff83f3651d8b752", - "reference": "7fe3d347f5e618bcea7d39345ff83f3651d8b752", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "athletic/athletic": "~0.1.6", - "phpmd/phpmd": "1.5.*", - "phpunit/phpunit": ">=3.7", - "satooshi/php-coveralls": "~0.6", - "squizlabs/php_codesniffer": "1.4.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "LazyMap\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/", - "role": "Developer" - } - ], - "description": "A library that provides lazy instantiation logic for a map of objects", - "homepage": "https://github.com/Ocramius/LazyMap", - "keywords": [ - "lazy", - "lazy instantiation", - "lazy loading", - "map", - "service location" - ], - "time": "2013-11-09 22:30:54" - }, { "name": "phpdocumentor/reflection-docblock", "version": "2.0.3", @@ -1054,16 +941,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.2.6", + "version": "4.3.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c28a790620fe30b049bb693be1ef9cd4e0fe906c" + "reference": "06005259429c156c02596add91f6a59c7dc3d4af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c28a790620fe30b049bb693be1ef9cd4e0fe906c", - "reference": "c28a790620fe30b049bb693be1ef9cd4e0fe906c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/06005259429c156c02596add91f6a59c7dc3d4af", + "reference": "06005259429c156c02596add91f6a59c7dc3d4af", "shasum": "" }, "require": { @@ -1077,7 +964,7 @@ "phpunit/php-file-iterator": "~1.3.1", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "~1.0.2", - "phpunit/phpunit-mock-objects": "~2.2", + "phpunit/phpunit-mock-objects": "~2.3", "sebastian/comparator": "~1.0", "sebastian/diff": "~1.1", "sebastian/environment": "~1.0", @@ -1094,7 +981,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2.x-dev" + "dev-master": "4.3.x-dev" } }, "autoload": { @@ -1124,29 +1011,29 @@ "testing", "xunit" ], - "time": "2014-09-14 09:31:24" + "time": "2014-10-06 06:20:35" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.2.1", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "b241b18d87a47093f20fae8b0ba40379b00bd53a" + "reference": "c63d2367247365f688544f0d500af90a11a44c65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b241b18d87a47093f20fae8b0ba40379b00bd53a", - "reference": "b241b18d87a47093f20fae8b0ba40379b00bd53a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", + "reference": "c63d2367247365f688544f0d500af90a11a44c65", "shasum": "" }, "require": { - "ocramius/instantiator": "~1.0", + "doctrine/instantiator": "~1.0,>=1.0.1", "php": ">=5.3.3", "phpunit/php-text-template": "~1.2" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "~4.3" }, "suggest": { "ext-soap": "*" @@ -1154,7 +1041,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "2.3.x-dev" } }, "autoload": { @@ -1179,7 +1066,7 @@ "mock", "xunit" ], - "time": "2014-09-06 17:32:37" + "time": "2014-10-03 05:12:11" }, { "name": "pimple/pimple", @@ -1229,16 +1116,16 @@ }, { "name": "sebastian/comparator", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2" + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", - "reference": "f7069ee51fa9fb6c038e16a9d0e3439f5449dcf2", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", "shasum": "" }, "require": { @@ -1265,11 +1152,6 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1281,6 +1163,10 @@ { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], "description": "Provides the functionality to compare PHP values for equality", @@ -1290,29 +1176,32 @@ "compare", "equality" ], - "time": "2014-05-02 07:05:58" + "time": "2014-05-11 23:00:21" }, { "name": "sebastian/diff", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d" + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", - "reference": "1e091702a5a38e6b4c1ba9ca816e3dd343df2e2d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -1325,14 +1214,13 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, { "name": "Kore Nordmann", "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], "description": "Diff implementation", @@ -1340,32 +1228,32 @@ "keywords": [ "diff" ], - "time": "2013-08-03 16:46:33" + "time": "2014-08-15 10:29:00" }, { "name": "sebastian/environment", - "version": "1.0.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a" + "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/79517609ec01139cd7e9fded0dd7ce08c952ef6a", - "reference": "79517609ec01139cd7e9fded0dd7ce08c952ef6a", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7", + "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "4.0.*@dev" + "phpunit/phpunit": "~4.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -1380,8 +1268,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], "description": "Provides functionality to handle HHVM/PHP environments", @@ -1391,27 +1278,27 @@ "environment", "hhvm" ], - "time": "2014-02-18 16:17:19" + "time": "2014-10-07 09:23:16" }, { "name": "sebastian/exporter", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529" + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", - "reference": "1f9a98e6f5dfe0524cb8c6166f7c82f3e9ae1529", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "4.0.*@dev" + "phpunit/phpunit": "~4.0" }, "type": "library", "extra": { @@ -1429,11 +1316,6 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1442,14 +1324,17 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net", - "role": "Lead" - }, { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -1458,7 +1343,7 @@ "export", "exporter" ], - "time": "2014-02-16 08:26:31" + "time": "2014-09-10 00:51:36" }, { "name": "sebastian/version", @@ -1497,17 +1382,17 @@ }, { "name": "symfony/console", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "748beed2a1e73179c3f5154d33fe6ae100c1aeb1" + "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/748beed2a1e73179c3f5154d33fe6ae100c1aeb1", - "reference": "748beed2a1e73179c3f5154d33fe6ae100c1aeb1", + "url": "https://api.github.com/repos/symfony/Console/zipball/ca053eaa031c93afb68a71e4eb1f4168dfd4a661", + "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661", "shasum": "" }, "require": { @@ -1548,21 +1433,21 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-08-14 16:10:54" + "time": "2014-09-25 09:53:56" }, { "name": "symfony/event-dispatcher", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b" + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", - "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f6281337bf5f985f585d1db6a83adb05ce531f46", + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46", "shasum": "" }, "require": { @@ -1571,7 +1456,7 @@ "require-dev": { "psr/log": "~1.0", "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.0", + "symfony/dependency-injection": "~2.0,<2.6.0", "symfony/stopwatch": "~2.2" }, "suggest": { @@ -1605,21 +1490,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-07-28 13:20:46" + "time": "2014-09-28 15:56:11" }, { "name": "symfony/finder", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "f40854d1a19c339c7f969f8f6d6d6e9153311c4c" + "reference": "d5033742b9a6206ef6d06e813870bca18e9205df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/f40854d1a19c339c7f969f8f6d6d6e9153311c4c", - "reference": "f40854d1a19c339c7f969f8f6d6d6e9153311c4c", + "url": "https://api.github.com/repos/symfony/Finder/zipball/d5033742b9a6206ef6d06e813870bca18e9205df", + "reference": "d5033742b9a6206ef6d06e813870bca18e9205df", "shasum": "" }, "require": { @@ -1652,21 +1537,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-09-03 09:00:14" + "time": "2014-09-27 08:35:39" }, { "name": "symfony/yaml", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "01a7695bcfb013d0a15c6757e15aae120342986f" + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/01a7695bcfb013d0a15c6757e15aae120342986f", - "reference": "01a7695bcfb013d0a15c6757e15aae120342986f", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", "shasum": "" }, "require": { @@ -1699,7 +1584,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-08-31 03:22:04" + "time": "2014-09-22 09:14:18" }, { "name": "zeptech/annotations", From 5d93737396857eee47c868523084b1b66d0ea6cd Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 9 Oct 2014 22:31:25 +0200 Subject: [PATCH 051/158] Branch status --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 54370dcd9..a97683d8d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![SensioLabsInsight](https://insight.sensiolabs.com/projects/699a9a78-39aa-41d0-bb60-41dbf0f1251d/big.png)](https://insight.sensiolabs.com/projects/699a9a78-39aa-41d0-bb60-41dbf0f1251d) - * [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) - * [![Dependency Status](https://www.versioneye.com/user/projects/54104e789e1622492d000025/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54104e789e1622492d000025) + * Master: [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) + * Develop: [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=develop)](https://travis-ci.org/corley/influxdb-php-sdk) Send metrics to InfluxDB and query for any data. From 42eb6d9dbb0cabf4207856581469a4c60b5be53a Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 9 Oct 2014 22:31:58 +0200 Subject: [PATCH 052/158] Bumped version 0.2.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ee1372d33..717903969 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.2 +0.2.3 From 425bda073c6ab5071cf5d6c1ed7d98202f902cbf Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Sat, 11 Oct 2014 00:21:05 +0200 Subject: [PATCH 053/158] Sockets usage --- README.md | 20 +++++++++++++++++++- composer.json | 3 ++- composer.lock | 20 +++++++------------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a97683d8d..ef5a97523 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,27 @@ Actually we supports two adapters ### Using UDP/IP Adapter -Actually "socket" php library is used for UDP/IP adapter +In order to use the UDP/IP adapter your must have PHP compiled with the `sockets` extension. + +To verify if you have the `sockets` extension just issue a: + +```bash +php -m | grep sockets ``` + +If you don't have the `sockets` extension, you can proceed in two ways: + +- Recompile your PHP whith the `--enable-sockets` flag +- Or just compile the `sockets` extension extracting it from the PHP source. + 1. Download the source relative to the PHP version that you on from [here](https://github.com/php/php-src/releases) + 2. Enter in the `ext/sockets` directory + 3. Issue a `phpize && ./configure && make -j && sudo make install` + 4. Add `extension=sockets.so` to your php.ini + +**Usage** + +```php $options = new Options(); $adapter = new UdpAdapter($options); diff --git a/composer.json b/composer.json index 9d09071c1..729eaa9d9 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "require-dev": { "phpspec/phpspec": "2.*", "phpunit/phpunit": "4.*", - "athletic/athletic": "~0.1" + "athletic/athletic": "~0.1", + "ext-sockets": "*" }, "homepage": "http://www.corley.it/", "keywords": ["influxdb", "udp", "sdk"], diff --git a/composer.lock b/composer.lock index 5e318be9e..da029aebb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ff63d84450d0ba675f2231b385344e9a", + "hash": "b8984634251cdc10c12d585b63e98fbd", "packages": [ { "name": "guzzlehttp/guzzle", @@ -1627,18 +1627,12 @@ "time": "2013-05-29 02:35:23" } ], - "aliases": [ - - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": [ - - ], + "stability-flags": [], "prefer-stable": false, - "platform": [ - - ], - "platform-dev": [ - - ] + "platform": [], + "platform-dev": { + "ext-sockets": "*" + } } From 6e7894ddef8a6e72b5f138f46b9469412b5ce74f Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 18 Nov 2014 14:40:26 +0100 Subject: [PATCH 054/158] Updated dependencies --- composer.lock | 86 +++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/composer.lock b/composer.lock index da029aebb..aebf066d2 100644 --- a/composer.lock +++ b/composer.lock @@ -332,20 +332,20 @@ }, { "name": "doctrine/instantiator", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8806c41c178ad4a2e87294b851d730779555d252" + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8806c41c178ad4a2e87294b851d730779555d252", - "reference": "8806c41c178ad4a2e87294b851d730779555d252", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", "shasum": "" }, "require": { - "php": "~5.3" + "php": ">=5.3,<8.0-DEV" }, "require-dev": { "athletic/athletic": "~0.1.8", @@ -382,7 +382,7 @@ "constructor", "instantiate" ], - "time": "2014-10-04 22:48:25" + "time": "2014-10-13 12:58:55" }, { "name": "kevinlebrun/colors.php", @@ -635,16 +635,16 @@ }, { "name": "phpspec/prophecy", - "version": "v1.2.1", + "version": "v1.3.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "ed9c0bcffe4639a5b0ff83e399eeb28e7fcc68f0" + "reference": "9ca52329bcdd1500de24427542577ebf3fc2f1c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/ed9c0bcffe4639a5b0ff83e399eeb28e7fcc68f0", - "reference": "ed9c0bcffe4639a5b0ff83e399eeb28e7fcc68f0", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/9ca52329bcdd1500de24427542577ebf3fc2f1c9", + "reference": "9ca52329bcdd1500de24427542577ebf3fc2f1c9", "shasum": "" }, "require": { @@ -690,7 +690,7 @@ "spy", "stub" ], - "time": "2014-09-23 10:52:18" + "time": "2014-11-17 16:23:49" }, { "name": "phpunit/php-code-coverage", @@ -941,16 +941,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.3.1", + "version": "4.3.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "06005259429c156c02596add91f6a59c7dc3d4af" + "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/06005259429c156c02596add91f6a59c7dc3d4af", - "reference": "06005259429c156c02596add91f6a59c7dc3d4af", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2dab9d593997db4abcf58d0daf798eb4e9cecfe1", + "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1", "shasum": "" }, "require": { @@ -961,7 +961,7 @@ "ext-spl": "*", "php": ">=5.3.3", "phpunit/php-code-coverage": "~2.0", - "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-file-iterator": "~1.3.2", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "~1.0.2", "phpunit/phpunit-mock-objects": "~2.3", @@ -1011,7 +1011,7 @@ "testing", "xunit" ], - "time": "2014-10-06 06:20:35" + "time": "2014-11-11 10:11:09" }, { "name": "phpunit/phpunit-mock-objects", @@ -1232,16 +1232,16 @@ }, { "name": "sebastian/environment", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7" + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7", - "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d", + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d", "shasum": "" }, "require": { @@ -1253,7 +1253,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -1278,7 +1278,7 @@ "environment", "hhvm" ], - "time": "2014-10-07 09:23:16" + "time": "2014-10-22 06:38:05" }, { "name": "sebastian/exporter", @@ -1382,17 +1382,17 @@ }, { "name": "symfony/console", - "version": "v2.5.5", + "version": "v2.5.6", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661" + "reference": "6f177fca24200a5b97aef5ce7a5c98124a0f0db0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ca053eaa031c93afb68a71e4eb1f4168dfd4a661", - "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661", + "url": "https://api.github.com/repos/symfony/Console/zipball/6f177fca24200a5b97aef5ce7a5c98124a0f0db0", + "reference": "6f177fca24200a5b97aef5ce7a5c98124a0f0db0", "shasum": "" }, "require": { @@ -1433,21 +1433,21 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-09-25 09:53:56" + "time": "2014-10-05 13:57:04" }, { "name": "symfony/event-dispatcher", - "version": "v2.5.5", + "version": "v2.5.6", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46" + "reference": "804eb28dbbfba9ffdab21fe2066744906cea2212" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f6281337bf5f985f585d1db6a83adb05ce531f46", - "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/804eb28dbbfba9ffdab21fe2066744906cea2212", + "reference": "804eb28dbbfba9ffdab21fe2066744906cea2212", "shasum": "" }, "require": { @@ -1490,21 +1490,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-09-28 15:56:11" + "time": "2014-10-01 15:43:05" }, { "name": "symfony/finder", - "version": "v2.5.5", + "version": "v2.5.6", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "d5033742b9a6206ef6d06e813870bca18e9205df" + "reference": "cf66df4e783e6aade319b273c9bcf9e42aa9b10f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/d5033742b9a6206ef6d06e813870bca18e9205df", - "reference": "d5033742b9a6206ef6d06e813870bca18e9205df", + "url": "https://api.github.com/repos/symfony/Finder/zipball/cf66df4e783e6aade319b273c9bcf9e42aa9b10f", + "reference": "cf66df4e783e6aade319b273c9bcf9e42aa9b10f", "shasum": "" }, "require": { @@ -1537,21 +1537,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-09-27 08:35:39" + "time": "2014-10-01 05:50:18" }, { "name": "symfony/yaml", - "version": "v2.5.5", + "version": "v2.5.6", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", - "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/2d9f527449cabfa8543dd7fa3a466d6ae83d6726", + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726", "shasum": "" }, "require": { @@ -1584,7 +1584,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-09-22 09:14:18" + "time": "2014-10-01 05:50:18" }, { "name": "zeptech/annotations", From 0ba7aa7829952c8f9366303252ea1700d51b34fa Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 18 Nov 2014 14:46:14 +0100 Subject: [PATCH 055/158] Bumped version 0.2.4 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 717903969..abd410582 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.3 +0.2.4 From d789328ac0bd4a461c3e4741f8580b7ccd800c4d Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Thu, 15 Jan 2015 00:46:01 +0100 Subject: [PATCH 056/158] Add phpdoc --- src/InfluxDB/Adapter/AdapterInterface.php | 8 +++ src/InfluxDB/Adapter/GuzzleAdapter.php | 33 +++++++++ src/InfluxDB/Adapter/QueryableInterface.php | 24 +++++++ src/InfluxDB/Adapter/UdpAdapter.php | 13 ++++ src/InfluxDB/Client.php | 58 ++++++++++++++++ src/InfluxDB/ClientFactory.php | 10 +++ src/InfluxDB/Filter/ColumnsPointsFilter.php | 6 ++ src/InfluxDB/Filter/FilterInterface.php | 7 ++ src/InfluxDB/Options.php | 75 +++++++++++++++++++++ 9 files changed, 234 insertions(+) diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php index 79ed18670..73d1b2fe5 100644 --- a/src/InfluxDB/Adapter/AdapterInterface.php +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -1,7 +1,15 @@ httpClient = $httpClient; $this->options = $options; } + /** + * @return Options + */ public function getOptions() { return $this->options; } + /** + * {@inheritDoc} + */ public function send($message, $timePrecision = false) { $httpMessage = [ @@ -35,6 +56,9 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface return $this->httpClient->post($endpoint, $httpMessage); } + /** + * {@inheritDoc} + */ public function query($query, $timePrecision = false) { $options = [ @@ -53,6 +77,9 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface return $this->httpClient->get($endpoint, $options)->json(); } + /** + * {@inheritDoc} + */ public function getDatabases() { $options = [ @@ -64,6 +91,9 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface return $this->httpClient->get($endpoint, $options)->json(); } + /** + * {@inheritDoc} + */ public function createDatabase($name) { $httpMessage = [ @@ -75,6 +105,9 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface return $this->httpClient->post($endpoint, $httpMessage)->json(); } + /** + * {@inheritDoc} + */ public function deleteDatabase($name) { $httpMessage = [ diff --git a/src/InfluxDB/Adapter/QueryableInterface.php b/src/InfluxDB/Adapter/QueryableInterface.php index 2e4754011..3bed92384 100644 --- a/src/InfluxDB/Adapter/QueryableInterface.php +++ b/src/InfluxDB/Adapter/QueryableInterface.php @@ -1,10 +1,34 @@ options = $options; } + /** + * @return Options + */ public function getOptions() { return $this->options; } + /** + * {@inheritDoc} + */ public function send($message, $timePrecision = false) { $message = json_encode($message); diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 94e879f8f..b7215244f 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -5,33 +5,68 @@ namespace InfluxDB; use InfluxDb\Adapter\QueryableInterface; use InfluxDB\Filter\FilterInterface; +/** + * Client to manage request at InfluxDB + */ class Client { + /** + * @var \InfluxDB\Adapter\AdapterInterface + */ private $adapter; + + /** + * @var \InfluxDB\Filter\FilterInterface + */ private $filter; + /** + * Set filter + * @param Filter\FilterInterface $filter + * @return Client + */ public function setFilter(Filter\FilterInterface $filter) { $this->filter = $filter; return $this; } + /** + * Get filter + * @return Filter\FilterInterface + */ public function getFilter() { return $this->filter; } + /** + * Set InfluxDB adapter + * @param Adapter\AdapterInterface + * @return Client + */ public function setAdapter(Adapter\AdapterInterface $adapter) { $this->adapter = $adapter; return $this; } + /** + * Get adapter + * @return Adapter\AdapterInterface + */ public function getAdapter() { return $this->adapter; } + /** + * Insert point into series + * @param string $name + * @param array $value + * @param bool|string $timePrecision + * @return mixed + */ public function mark($name, array $values, $timePrecision = false) { $data =[]; @@ -45,6 +80,12 @@ class Client return $this->getAdapter()->send([$data], $timePrecision); } + /** + * Make a query into database + * @param string $query + * @param bool|string $timePrecision + * @return array + */ public function query($query, $timePrecision = false) { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -62,6 +103,10 @@ class Client return $return; } + /** + * List of databases + * @return array + */ public function getDatabases() { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -70,6 +115,10 @@ class Client return $this->getAdapter()->getDatabases(); } + /** + * Create database by name + * @param string $name + */ public function createDatabase($name) { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -78,6 +127,10 @@ class Client return $this->getAdapter()->createDatabase($name); } + /** + * Delete database by name + * @param string $name + */ public function deleteDatabase($name) { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -86,6 +139,11 @@ class Client return $this->getAdapter()->deleteDatabase($name); } + /** + * List of time precision choose + * @param string $timePrecision + * @return bool|string + */ private function clearTimePrecision($timePrecision) { switch ($timePrecision) { diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php index cd94929f6..da987220c 100644 --- a/src/InfluxDB/ClientFactory.php +++ b/src/InfluxDB/ClientFactory.php @@ -4,8 +4,18 @@ namespace InfluxDB; use Zend\Stdlib\Hydrator\ClassMethods; use GuzzleHttp\Client as GuzzleClient; +/** + * Create your static client + */ abstract class ClientFactory { + /** + * Create new client + * @param array $options + * @return Client + * @throws InvalidArgumentException If not exist adapter name + * or not find adapter + */ public static function create(array $options) { $defaultOptions = [ diff --git a/src/InfluxDB/Filter/ColumnsPointsFilter.php b/src/InfluxDB/Filter/ColumnsPointsFilter.php index b6e94dc07..54e9ff127 100644 --- a/src/InfluxDB/Filter/ColumnsPointsFilter.php +++ b/src/InfluxDB/Filter/ColumnsPointsFilter.php @@ -2,8 +2,14 @@ namespace InfluxDB\Filter; +/** + * This filter manipulates response + */ class ColumnsPointsFilter implements FilterInterface { + /** + * {@inheritDoc} + */ public function filter($metrics) { $response = []; diff --git a/src/InfluxDB/Filter/FilterInterface.php b/src/InfluxDB/Filter/FilterInterface.php index 01bb59fd8..b2999a52a 100644 --- a/src/InfluxDB/Filter/FilterInterface.php +++ b/src/InfluxDB/Filter/FilterInterface.php @@ -1,7 +1,14 @@ host = "localhost"; @@ -21,17 +49,27 @@ class Options $this->setProtocol("http"); } + /** + * @return string + */ public function getProtocol() { return $this->protocol; } + /** + * @param string $protocol + * @return Options + */ public function setProtocol($protocol) { $this->protocol = $protocol; return $this; } + /** + * @return string + */ public function getHost() { return $this->host; @@ -43,50 +81,82 @@ class Options return $this; } + /** + * @return string|int + */ public function getPort() { return $this->port; } + /** + * @param string|int $port + * @return Options + */ public function setPort($port) { $this->port = $port; return $this; } + /** + * @return string + */ public function getUsername() { return $this->username; } + /** + * @param string $usarname + * @return Options + */ public function setUsername($username) { $this->username = $username; return $this; } + /** + * @return string + */ public function getPassword() { return $this->password; } + /** + * @param string $password + * @return Options + */ public function setPassword($password) { $this->password = $password; return $this; } + /** + * @return string + */ public function getDatabase() { return $this->database; } + /** + * @param string $database + * @return Options + */ public function setDatabase($database) { $this->database = $database; return $this; } + /** + * Build http series edpoint + * @return string + */ public function getHttpSeriesEndpoint() { return sprintf( @@ -98,6 +168,11 @@ class Options ); } + /** + * Build http database endpoint by name + * @param string $name + * @return string + */ public function getHttpDatabaseEndpoint($name = false) { $url = sprintf( From 64aa8b45d32fccd5fa6d60b0563bce3058a3c351 Mon Sep 17 00:00:00 2001 From: lekz Date: Mon, 2 Mar 2015 21:37:37 +0200 Subject: [PATCH 057/158] Added new HttpAdapter --- README.md | 17 +- spec/InfluxDB/Adapter/HttpAdapterSpec.php | 194 +++++++++++++++++ src/InfluxDB/Adapter/GuzzleAdapter.php | 6 + src/InfluxDB/Adapter/HttpAdapter.php | 198 ++++++++++++++++++ src/InfluxDB/ClientFactory.php | 3 + .../InfluxAuthorizationException.php | 8 + .../Exception/InfluxBadResponseException.php | 8 + .../Exception/InfluxGeneralException.php | 8 + .../Exception/InfluxNoSeriesException.php | 8 + .../InfluxUnexpectedResponseException.php | 8 + tests/InfluxDB/ClientFactoryTest.php | 22 +- tests/InfluxDB/HttpAdapterTest.php | 128 +++++++++++ 12 files changed, 597 insertions(+), 11 deletions(-) create mode 100755 spec/InfluxDB/Adapter/HttpAdapterSpec.php create mode 100644 src/InfluxDB/Adapter/HttpAdapter.php create mode 100644 src/InfluxDB/Exception/InfluxAuthorizationException.php create mode 100644 src/InfluxDB/Exception/InfluxBadResponseException.php create mode 100644 src/InfluxDB/Exception/InfluxGeneralException.php create mode 100644 src/InfluxDB/Exception/InfluxNoSeriesException.php create mode 100644 src/InfluxDB/Exception/InfluxUnexpectedResponseException.php create mode 100644 tests/InfluxDB/HttpAdapterTest.php diff --git a/README.md b/README.md index ef5a97523..ac7051628 100644 --- a/README.md +++ b/README.md @@ -77,21 +77,28 @@ $client = new Client(); $client->setAdapter($adapter); ``` -### Using HTTP Adapter +### Using HTTP Adapters Actually Guzzle is used as HTTP client library ```php setAdapter($adapter); ``` +#### Supported types of exceptions + +* InfluxGeneralException +* InfluxAuthorizationException (extends InfluxGeneralException) +* InfluxBadResponseException (extends InfluxGeneralException) +* InfluxNoSeriesException (extends InfluxGeneralException) +* InfluxUnexpectedResponseException (extends InfluxGeneralException) + ### Create your client with the factory method Effectively the client creation is not so simple, for that @@ -100,7 +107,7 @@ reason you can you the factory method provided with the library. ```php $options = [ "adapter" => [ - "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + "name" => "InfluxDB\\Adapter\\HttpAdapter", "options" => [ // guzzle options ], @@ -144,7 +151,7 @@ $influx->query("select * from mine", "s"); // with time_precision ``` You can query the database only if the adapter is queryable (implements -`QueryableInterface`), actually `GuzzleAdapter`. +`QueryableInterface`), actually `HttpAdapter`. The adapter returns the json decoded body of the InfluxDB response, something like: diff --git a/spec/InfluxDB/Adapter/HttpAdapterSpec.php b/spec/InfluxDB/Adapter/HttpAdapterSpec.php new file mode 100755 index 000000000..fac255668 --- /dev/null +++ b/spec/InfluxDB/Adapter/HttpAdapterSpec.php @@ -0,0 +1,194 @@ +shouldHaveType('InfluxDB\Adapter\HttpAdapter'); + } + + function let(Options $options, Client $client) + { + $options->getHttpSeriesEndpoint()->willReturn("localhost"); + $options->getHttpDatabaseEndpoint()->willReturn("localhost"); + $options->getUsername()->willReturn("one"); + $options->getPassword()->willReturn("two"); + $this->beConstructedWith($options, $client); + } + + function it_should_send_data_via_post(Client $client) + { + $responseBody = ['key'=>'value']; + $response = new Response(200,[], Stream::factory(json_encode($responseBody))); + $client->post("localhost", [ + 'auth' => ["one", "two"], + 'exceptions' => false, + 'body' => json_encode(['pippo']) + ])->willReturn($response) + ->shouldBeCalledTimes(1); + $this->send(["pippo"])->shouldReturn($responseBody); + } + + function it_should_query_data(Client $client, Options $options) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(200,[],null)); + $this->query("select * from tcp.test")->shouldReturn(null); + } + + function it_should_query_data_with_time_precision(Client $client, Options $options) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "time_precision" => "s", + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(200, [], null)); + $this->query("select * from tcp.test", "s")->shouldReturn(null); + } + + function it_should_list_all_databases(Client $client, Options $options) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + ] + )->shouldBeCalledTimes(1)->willReturn(new Response(200, [], null)); + + $this->getDatabases()->shouldReturn(null); + } + + function it_should_create_a_new_database(Client $client, Options $options) + { + $client->post( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "body" => json_encode(["name" => "db_name"]) + ] + )->shouldBeCalledTimes(1)->willReturn(new Response(201, [], null)); + + $this->createDatabase("db_name")->shouldReturn(true); + } + + function it_should_return_true_with_success(Client $client) { + foreach ([201,204,299] as $code) { + $client->post(Argument::any(), Argument::any(), Argument::any())->willReturn(new Response($code, [], null)); + + $this->createDatabase("db_name")->shouldReturn(true); + } + } + + + + function it_should_throw_no_series_exception (Client $client) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(HttpAdapter::STATUS_CODE_BAD_REQUEST,[], Stream::factory("Couldn't find series: tcp.test"))); + $this->shouldThrow(new InfluxNoSeriesException("Couldn't find series: tcp.test", HttpAdapter::STATUS_CODE_BAD_REQUEST)) + ->during("query", ["select * from tcp.test"]); + } + + function it_should_throw_authorization_exception (Client $client) + { + $codes = [HttpAdapter::STATUS_CODE_UNAUTHORIZED, HttpAdapter::STATUS_CODE_FORBIDDEN]; + foreach ($codes as $code) { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response($code,[], Stream::factory("Message"))); + $this->shouldThrow(new InfluxAuthorizationException("Message", $code)) + ->during("query", ["select * from tcp.test"]); + } + } + + function it_should_throw_general_exception (Client $client) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(409,[], Stream::factory("Message"))); + $this->shouldThrow(new InfluxGeneralException("Message", 409)) + ->during("query", ["select * from tcp.test"]); + } + + function it_should_throw_general_exception_with_default_message (Client $client) + { + $client->get(Argument::any(), Argument::any())->willReturn(new Response(409)); + $this->shouldThrow(new InfluxGeneralException("Conflict", 409)) + ->during("query", ["select * from tcp.test"]); + } + + function it_should_throw_bad_response_exception(Client $client) + { + $response = new Response(200,[], Stream::factory('bad response')); + $client->post("localhost", [ + 'auth' => ["one", "two"], + 'exceptions' => false, + 'body' => json_encode(['pippo']) + ])->willReturn($response) + ->shouldBeCalledTimes(1); + $this->shouldThrow(new InfluxBadResponseException("Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON; Response is 'bad response'", 0)) + ->during("send", [["pippo"]]); + } + + function it_should_throw_unexpected_response_exception (Client $client) + { + foreach ([0, 300, 500] as $code) { + $client->get(Argument::any(), Argument::any())->willReturn(new Response($code, [], Stream::factory("Message"))); + $this->shouldThrow(new InfluxUnexpectedResponseException("Message", $code)) + ->during("query", ["select * from tcp.test"]); + } + } +} diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 72695edf4..f3b8b2a98 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -4,6 +4,12 @@ namespace InfluxDB\Adapter; use GuzzleHttp\Client; use InfluxDB\Options; +/** + * Class GuzzleAdapter + * @package InfluxDB\Adapter + * + * @deprecated + */ class GuzzleAdapter implements AdapterInterface, QueryableInterface { private $httpClient; diff --git a/src/InfluxDB/Adapter/HttpAdapter.php b/src/InfluxDB/Adapter/HttpAdapter.php new file mode 100644 index 000000000..738f43c83 --- /dev/null +++ b/src/InfluxDB/Adapter/HttpAdapter.php @@ -0,0 +1,198 @@ +options = $options; + $this->client = $client ?: new Client(); + } + + /** + * @return Options + */ + public function getOptions() + { + return $this->options; + } + + /** + * @param array $body + * @param array $query + * @param bool $timePrecision + * @return array + */ + protected function getRequest(array $body = [], array $query = [], $timePrecision = false) + { + $request = [ + "auth" => [$this->options->getUsername(), $this->options->getPassword()], + "exceptions" => false + ]; + if (count($body)) { + $request['body'] = json_encode($body); + } + if (count($query)) { + $request['query'] = $query; + } + if ($timePrecision) { + $request["query"]["time_precision"] = $timePrecision; + } + return $request; + } + + /** + * @param ResponseInterface $response + * @return mixed + * @throws \InfluxDB\Exception\InfluxGeneralException + * @throws \InfluxDB\Exception\InfluxAuthorizationException + * @throws \InfluxDB\Exception\InfluxNoSeriesException + */ + protected function parseResponse(ResponseInterface $response) + { + $statusCode = $response->getStatusCode(); + if ($statusCode >= 400 && $statusCode < 500) { + $message = (string)$response->getBody(); + if (!$message) { + $message = $response->getReasonPhrase(); + } + switch ($statusCode) { + case self::STATUS_CODE_UNAUTHORIZED: + case self::STATUS_CODE_FORBIDDEN: + throw new InfluxAuthorizationException($message, $statusCode); + case self::STATUS_CODE_BAD_REQUEST: + if (strpos($message, "Couldn't find series:") !== false) { + throw new InfluxNoSeriesException($message, $statusCode); + } + } + throw new InfluxGeneralException($message, $statusCode); + } else if ($statusCode == self::STATUS_CODE_OK) { + try { + return $response->json(); + } catch (ParseException $ex) { + throw new InfluxBadResponseException( + sprintf("%s; Response is '%s'", $ex->getMessage(), (string)$response->getBody()), + $ex->getCode(), $ex + ); + } + } else if ($statusCode > 200 && $statusCode < 300) { + return true; + } + throw new InfluxUnexpectedResponseException((string)$response->getBody(), $statusCode); + } + + /** + * @param $message + * @param bool $timePrecision + * @return \GuzzleHttp\Message\ResponseInterface + */ + public function send($message, $timePrecision = false) + { + try { + $response = $this->client->post( + $this->options->getHttpSeriesEndpoint(), + $this->getRequest($message, [], $timePrecision) + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @param $query + * @param bool $timePrecision + * @return mixed + */ + public function query($query, $timePrecision = false) + { + try { + $response = $this->client->get( + $this->options->getHttpSeriesEndpoint(), + $this->getRequest([], ["q" => $query], $timePrecision) + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @return mixed + */ + public function getDatabases() + { + try { + $response = $this->client->get( + $this->options->getHttpDatabaseEndpoint(), + $this->getRequest() + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @param $name + * @return mixed + */ + public function createDatabase($name) + { + try { + $response = $this->client->post( + $this->options->getHttpDatabaseEndpoint(), + $this->getRequest(["name" => $name]) + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @param $name + * @return mixed + */ + public function deleteDatabase($name) + { + try { + $response = $this->client->delete( + $this->options->getHttpDatabaseEndpoint($name), + $this->getRequest() + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } +} \ No newline at end of file diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php index cd94929f6..df62a6465 100644 --- a/src/InfluxDB/ClientFactory.php +++ b/src/InfluxDB/ClientFactory.php @@ -38,6 +38,9 @@ abstract class ClientFactory case 'InfluxDB\\Adapter\\GuzzleAdapter': $adapter = new $adapterName(new GuzzleClient($options["adapter"]["options"]), $adapterOptions); break; + case 'InfluxDB\\Adapter\\HttpAdapter': + $adapter = new $adapterName($adapterOptions, new GuzzleClient($options["adapter"]["options"])); + break; default: throw new \InvalidArgumentException("Missing adapter {$adapter}"); } diff --git a/src/InfluxDB/Exception/InfluxAuthorizationException.php b/src/InfluxDB/Exception/InfluxAuthorizationException.php new file mode 100644 index 000000000..f4feb823f --- /dev/null +++ b/src/InfluxDB/Exception/InfluxAuthorizationException.php @@ -0,0 +1,8 @@ + [ - "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + "name" => $adapter, ], "options" => [ "host" => "127.0.0.1", @@ -78,21 +79,30 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $client = ClientFactory::create($options); $this->assertInstanceOf("InfluxDB\\Client", $client); - $this->assertInstanceOf("InfluxDB\\Adapter\\GuzzleAdapter", $client->getAdapter()); + $this->assertInstanceOf($adapter, $client->getAdapter()); $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); } + public function getTcpAdapters() + { + return [ + ["InfluxDB\\Adapter\\GuzzleAdapter"], + ["InfluxDB\\Adapter\\HttpAdapter"], + ]; + } + /** * @group factory * @group filters + * @dataProvider getTcpAdapters */ - public function testCreateTcpClientWithFilter() + public function testCreateTcpClientWithFilter($adapter) { $options = [ "adapter" => [ - "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + "name" => $adapter, ], "options" => [ "host" => "127.0.0.1", @@ -109,7 +119,7 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $client = ClientFactory::create($options); $this->assertInstanceOf("InfluxDB\\Client", $client); - $this->assertInstanceOf("InfluxDB\\Adapter\\GuzzleAdapter", $client->getAdapter()); + $this->assertInstanceOf($adapter, $client->getAdapter()); $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); diff --git a/tests/InfluxDB/HttpAdapterTest.php b/tests/InfluxDB/HttpAdapterTest.php new file mode 100644 index 000000000..9d6871c83 --- /dev/null +++ b/tests/InfluxDB/HttpAdapterTest.php @@ -0,0 +1,128 @@ +rawOptions = $options; + + $tcpOptions = $options["tcp"]; + + $options = new Options(); + $options->setHost($tcpOptions["host"]); + $options->setPort($tcpOptions["port"]); + $options->setUsername($tcpOptions["username"]); + $options->setPassword($tcpOptions["password"]); + $options->setDatabase($tcpOptions["database"]); + + $this->options = $options; + + $adapter = new HttpAdapter($options); + + $influx = new Client(); + $influx->setAdapter($adapter); + $this->object = $influx; + + $databases = $this->object->getDatabases(); + foreach ($databases as $database) { + $this->object->deleteDatabase($database["name"]); + } + + $this->object->createDatabase($this->rawOptions["tcp"]["database"]); + } + + /** + * @group tcp + */ + public function testApiWorksCorrectly() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select * from tcp.test"); + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("element", $body[0]["points"][0][2]); + } + + /** + * @group tcp + */ + public function testQueryApiWorksCorrectly() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select * from tcp.test"); + + $this->assertCount(1, $body); + $this->assertEquals("tcp.test", $body[0]["name"]); + $this->assertEquals("element", $body[0]["points"][0][2]); + } + + /** + * @group tcp + */ + public function testQueryApiWithMultipleData() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + $this->object->mark("tcp.test", ["mark" => "element2"]); + $this->object->mark("tcp.test", ["mark" => "element3"]); + + $body = $this->object->query("select mark from tcp.test", "s"); + + $this->assertCount(3, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + } + + /** + * @group tcp + */ + public function testQueryApiWithTimePrecision() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select mark from tcp.test", "s"); + + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + } + + /** + * @group tcp + */ + public function testWriteApiWithTimePrecision() + { + $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); + + $body = $this->object->query("select mark from tcp.test", "ms"); + + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + + $this->assertEquals("1410591552000", $body[0]["points"][0][0]); + } + + public function testListActiveDatabses() + { + $databases = $this->object->getDatabases(); + + $this->assertCount(1, $databases); + } + + public function testCreateANewDatabase() + { + $this->object->createDatabase("walter"); + $databases = $this->object->getDatabases(); + + $this->assertCount(2, $databases); + + $this->object->deleteDatabase("walter"); + } +} From a8fe33a3815b1202e6f5ab1efc3a3c148459864d Mon Sep 17 00:00:00 2001 From: lekz Date: Mon, 2 Mar 2015 21:37:37 +0200 Subject: [PATCH 058/158] Added new HttpAdapter Conflicts: src/InfluxDB/Adapter/GuzzleAdapter.php --- README.md | 17 +- spec/InfluxDB/Adapter/HttpAdapterSpec.php | 194 +++++++++++++++++ src/InfluxDB/Adapter/GuzzleAdapter.php | 6 +- src/InfluxDB/Adapter/HttpAdapter.php | 198 ++++++++++++++++++ src/InfluxDB/ClientFactory.php | 3 + .../InfluxAuthorizationException.php | 8 + .../Exception/InfluxBadResponseException.php | 8 + .../Exception/InfluxGeneralException.php | 8 + .../Exception/InfluxNoSeriesException.php | 8 + .../InfluxUnexpectedResponseException.php | 8 + tests/InfluxDB/ClientFactoryTest.php | 22 +- tests/InfluxDB/HttpAdapterTest.php | 128 +++++++++++ 12 files changed, 595 insertions(+), 13 deletions(-) create mode 100755 spec/InfluxDB/Adapter/HttpAdapterSpec.php create mode 100644 src/InfluxDB/Adapter/HttpAdapter.php create mode 100644 src/InfluxDB/Exception/InfluxAuthorizationException.php create mode 100644 src/InfluxDB/Exception/InfluxBadResponseException.php create mode 100644 src/InfluxDB/Exception/InfluxGeneralException.php create mode 100644 src/InfluxDB/Exception/InfluxNoSeriesException.php create mode 100644 src/InfluxDB/Exception/InfluxUnexpectedResponseException.php create mode 100644 tests/InfluxDB/HttpAdapterTest.php diff --git a/README.md b/README.md index ef5a97523..ac7051628 100644 --- a/README.md +++ b/README.md @@ -77,21 +77,28 @@ $client = new Client(); $client->setAdapter($adapter); ``` -### Using HTTP Adapter +### Using HTTP Adapters Actually Guzzle is used as HTTP client library ```php setAdapter($adapter); ``` +#### Supported types of exceptions + +* InfluxGeneralException +* InfluxAuthorizationException (extends InfluxGeneralException) +* InfluxBadResponseException (extends InfluxGeneralException) +* InfluxNoSeriesException (extends InfluxGeneralException) +* InfluxUnexpectedResponseException (extends InfluxGeneralException) + ### Create your client with the factory method Effectively the client creation is not so simple, for that @@ -100,7 +107,7 @@ reason you can you the factory method provided with the library. ```php $options = [ "adapter" => [ - "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + "name" => "InfluxDB\\Adapter\\HttpAdapter", "options" => [ // guzzle options ], @@ -144,7 +151,7 @@ $influx->query("select * from mine", "s"); // with time_precision ``` You can query the database only if the adapter is queryable (implements -`QueryableInterface`), actually `GuzzleAdapter`. +`QueryableInterface`), actually `HttpAdapter`. The adapter returns the json decoded body of the InfluxDB response, something like: diff --git a/spec/InfluxDB/Adapter/HttpAdapterSpec.php b/spec/InfluxDB/Adapter/HttpAdapterSpec.php new file mode 100755 index 000000000..fac255668 --- /dev/null +++ b/spec/InfluxDB/Adapter/HttpAdapterSpec.php @@ -0,0 +1,194 @@ +shouldHaveType('InfluxDB\Adapter\HttpAdapter'); + } + + function let(Options $options, Client $client) + { + $options->getHttpSeriesEndpoint()->willReturn("localhost"); + $options->getHttpDatabaseEndpoint()->willReturn("localhost"); + $options->getUsername()->willReturn("one"); + $options->getPassword()->willReturn("two"); + $this->beConstructedWith($options, $client); + } + + function it_should_send_data_via_post(Client $client) + { + $responseBody = ['key'=>'value']; + $response = new Response(200,[], Stream::factory(json_encode($responseBody))); + $client->post("localhost", [ + 'auth' => ["one", "two"], + 'exceptions' => false, + 'body' => json_encode(['pippo']) + ])->willReturn($response) + ->shouldBeCalledTimes(1); + $this->send(["pippo"])->shouldReturn($responseBody); + } + + function it_should_query_data(Client $client, Options $options) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(200,[],null)); + $this->query("select * from tcp.test")->shouldReturn(null); + } + + function it_should_query_data_with_time_precision(Client $client, Options $options) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "time_precision" => "s", + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(200, [], null)); + $this->query("select * from tcp.test", "s")->shouldReturn(null); + } + + function it_should_list_all_databases(Client $client, Options $options) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + ] + )->shouldBeCalledTimes(1)->willReturn(new Response(200, [], null)); + + $this->getDatabases()->shouldReturn(null); + } + + function it_should_create_a_new_database(Client $client, Options $options) + { + $client->post( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "body" => json_encode(["name" => "db_name"]) + ] + )->shouldBeCalledTimes(1)->willReturn(new Response(201, [], null)); + + $this->createDatabase("db_name")->shouldReturn(true); + } + + function it_should_return_true_with_success(Client $client) { + foreach ([201,204,299] as $code) { + $client->post(Argument::any(), Argument::any(), Argument::any())->willReturn(new Response($code, [], null)); + + $this->createDatabase("db_name")->shouldReturn(true); + } + } + + + + function it_should_throw_no_series_exception (Client $client) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(HttpAdapter::STATUS_CODE_BAD_REQUEST,[], Stream::factory("Couldn't find series: tcp.test"))); + $this->shouldThrow(new InfluxNoSeriesException("Couldn't find series: tcp.test", HttpAdapter::STATUS_CODE_BAD_REQUEST)) + ->during("query", ["select * from tcp.test"]); + } + + function it_should_throw_authorization_exception (Client $client) + { + $codes = [HttpAdapter::STATUS_CODE_UNAUTHORIZED, HttpAdapter::STATUS_CODE_FORBIDDEN]; + foreach ($codes as $code) { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response($code,[], Stream::factory("Message"))); + $this->shouldThrow(new InfluxAuthorizationException("Message", $code)) + ->during("query", ["select * from tcp.test"]); + } + } + + function it_should_throw_general_exception (Client $client) + { + $client->get( + "localhost", + [ + "auth" => ["one", "two"], + "exceptions" => false, + "query" => [ + "q" => "select * from tcp.test", + ] + ] + )->willReturn(new Response(409,[], Stream::factory("Message"))); + $this->shouldThrow(new InfluxGeneralException("Message", 409)) + ->during("query", ["select * from tcp.test"]); + } + + function it_should_throw_general_exception_with_default_message (Client $client) + { + $client->get(Argument::any(), Argument::any())->willReturn(new Response(409)); + $this->shouldThrow(new InfluxGeneralException("Conflict", 409)) + ->during("query", ["select * from tcp.test"]); + } + + function it_should_throw_bad_response_exception(Client $client) + { + $response = new Response(200,[], Stream::factory('bad response')); + $client->post("localhost", [ + 'auth' => ["one", "two"], + 'exceptions' => false, + 'body' => json_encode(['pippo']) + ])->willReturn($response) + ->shouldBeCalledTimes(1); + $this->shouldThrow(new InfluxBadResponseException("Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON; Response is 'bad response'", 0)) + ->during("send", [["pippo"]]); + } + + function it_should_throw_unexpected_response_exception (Client $client) + { + foreach ([0, 300, 500] as $code) { + $client->get(Argument::any(), Argument::any())->willReturn(new Response($code, [], Stream::factory("Message"))); + $this->shouldThrow(new InfluxUnexpectedResponseException("Message", $code)) + ->during("query", ["select * from tcp.test"]); + } + } +} diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 5d8ca303c..f8fe908fc 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -5,8 +5,10 @@ use GuzzleHttp\Client; use InfluxDB\Options; /** - * Integration of Guzzle HttpClient how InfluxDB client adapter - * @link http://guzzle.readthedocs.org/en/latest/ + * Class GuzzleAdapter + * @package InfluxDB\Adapter + * + * @deprecated */ class GuzzleAdapter implements AdapterInterface, QueryableInterface { diff --git a/src/InfluxDB/Adapter/HttpAdapter.php b/src/InfluxDB/Adapter/HttpAdapter.php new file mode 100644 index 000000000..738f43c83 --- /dev/null +++ b/src/InfluxDB/Adapter/HttpAdapter.php @@ -0,0 +1,198 @@ +options = $options; + $this->client = $client ?: new Client(); + } + + /** + * @return Options + */ + public function getOptions() + { + return $this->options; + } + + /** + * @param array $body + * @param array $query + * @param bool $timePrecision + * @return array + */ + protected function getRequest(array $body = [], array $query = [], $timePrecision = false) + { + $request = [ + "auth" => [$this->options->getUsername(), $this->options->getPassword()], + "exceptions" => false + ]; + if (count($body)) { + $request['body'] = json_encode($body); + } + if (count($query)) { + $request['query'] = $query; + } + if ($timePrecision) { + $request["query"]["time_precision"] = $timePrecision; + } + return $request; + } + + /** + * @param ResponseInterface $response + * @return mixed + * @throws \InfluxDB\Exception\InfluxGeneralException + * @throws \InfluxDB\Exception\InfluxAuthorizationException + * @throws \InfluxDB\Exception\InfluxNoSeriesException + */ + protected function parseResponse(ResponseInterface $response) + { + $statusCode = $response->getStatusCode(); + if ($statusCode >= 400 && $statusCode < 500) { + $message = (string)$response->getBody(); + if (!$message) { + $message = $response->getReasonPhrase(); + } + switch ($statusCode) { + case self::STATUS_CODE_UNAUTHORIZED: + case self::STATUS_CODE_FORBIDDEN: + throw new InfluxAuthorizationException($message, $statusCode); + case self::STATUS_CODE_BAD_REQUEST: + if (strpos($message, "Couldn't find series:") !== false) { + throw new InfluxNoSeriesException($message, $statusCode); + } + } + throw new InfluxGeneralException($message, $statusCode); + } else if ($statusCode == self::STATUS_CODE_OK) { + try { + return $response->json(); + } catch (ParseException $ex) { + throw new InfluxBadResponseException( + sprintf("%s; Response is '%s'", $ex->getMessage(), (string)$response->getBody()), + $ex->getCode(), $ex + ); + } + } else if ($statusCode > 200 && $statusCode < 300) { + return true; + } + throw new InfluxUnexpectedResponseException((string)$response->getBody(), $statusCode); + } + + /** + * @param $message + * @param bool $timePrecision + * @return \GuzzleHttp\Message\ResponseInterface + */ + public function send($message, $timePrecision = false) + { + try { + $response = $this->client->post( + $this->options->getHttpSeriesEndpoint(), + $this->getRequest($message, [], $timePrecision) + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @param $query + * @param bool $timePrecision + * @return mixed + */ + public function query($query, $timePrecision = false) + { + try { + $response = $this->client->get( + $this->options->getHttpSeriesEndpoint(), + $this->getRequest([], ["q" => $query], $timePrecision) + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @return mixed + */ + public function getDatabases() + { + try { + $response = $this->client->get( + $this->options->getHttpDatabaseEndpoint(), + $this->getRequest() + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @param $name + * @return mixed + */ + public function createDatabase($name) + { + try { + $response = $this->client->post( + $this->options->getHttpDatabaseEndpoint(), + $this->getRequest(["name" => $name]) + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } + + /** + * @param $name + * @return mixed + */ + public function deleteDatabase($name) + { + try { + $response = $this->client->delete( + $this->options->getHttpDatabaseEndpoint($name), + $this->getRequest() + ); + } catch (\Exception $ex) { + throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); + } + return $this->parseResponse($response); + } +} \ No newline at end of file diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php index da987220c..a466cfc54 100644 --- a/src/InfluxDB/ClientFactory.php +++ b/src/InfluxDB/ClientFactory.php @@ -48,6 +48,9 @@ abstract class ClientFactory case 'InfluxDB\\Adapter\\GuzzleAdapter': $adapter = new $adapterName(new GuzzleClient($options["adapter"]["options"]), $adapterOptions); break; + case 'InfluxDB\\Adapter\\HttpAdapter': + $adapter = new $adapterName($adapterOptions, new GuzzleClient($options["adapter"]["options"])); + break; default: throw new \InvalidArgumentException("Missing adapter {$adapter}"); } diff --git a/src/InfluxDB/Exception/InfluxAuthorizationException.php b/src/InfluxDB/Exception/InfluxAuthorizationException.php new file mode 100644 index 000000000..f4feb823f --- /dev/null +++ b/src/InfluxDB/Exception/InfluxAuthorizationException.php @@ -0,0 +1,8 @@ + [ - "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + "name" => $adapter, ], "options" => [ "host" => "127.0.0.1", @@ -78,21 +79,30 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $client = ClientFactory::create($options); $this->assertInstanceOf("InfluxDB\\Client", $client); - $this->assertInstanceOf("InfluxDB\\Adapter\\GuzzleAdapter", $client->getAdapter()); + $this->assertInstanceOf($adapter, $client->getAdapter()); $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); } + public function getTcpAdapters() + { + return [ + ["InfluxDB\\Adapter\\GuzzleAdapter"], + ["InfluxDB\\Adapter\\HttpAdapter"], + ]; + } + /** * @group factory * @group filters + * @dataProvider getTcpAdapters */ - public function testCreateTcpClientWithFilter() + public function testCreateTcpClientWithFilter($adapter) { $options = [ "adapter" => [ - "name" => "InfluxDB\\Adapter\\GuzzleAdapter", + "name" => $adapter, ], "options" => [ "host" => "127.0.0.1", @@ -109,7 +119,7 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $client = ClientFactory::create($options); $this->assertInstanceOf("InfluxDB\\Client", $client); - $this->assertInstanceOf("InfluxDB\\Adapter\\GuzzleAdapter", $client->getAdapter()); + $this->assertInstanceOf($adapter, $client->getAdapter()); $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); diff --git a/tests/InfluxDB/HttpAdapterTest.php b/tests/InfluxDB/HttpAdapterTest.php new file mode 100644 index 000000000..9d6871c83 --- /dev/null +++ b/tests/InfluxDB/HttpAdapterTest.php @@ -0,0 +1,128 @@ +rawOptions = $options; + + $tcpOptions = $options["tcp"]; + + $options = new Options(); + $options->setHost($tcpOptions["host"]); + $options->setPort($tcpOptions["port"]); + $options->setUsername($tcpOptions["username"]); + $options->setPassword($tcpOptions["password"]); + $options->setDatabase($tcpOptions["database"]); + + $this->options = $options; + + $adapter = new HttpAdapter($options); + + $influx = new Client(); + $influx->setAdapter($adapter); + $this->object = $influx; + + $databases = $this->object->getDatabases(); + foreach ($databases as $database) { + $this->object->deleteDatabase($database["name"]); + } + + $this->object->createDatabase($this->rawOptions["tcp"]["database"]); + } + + /** + * @group tcp + */ + public function testApiWorksCorrectly() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select * from tcp.test"); + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("element", $body[0]["points"][0][2]); + } + + /** + * @group tcp + */ + public function testQueryApiWorksCorrectly() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select * from tcp.test"); + + $this->assertCount(1, $body); + $this->assertEquals("tcp.test", $body[0]["name"]); + $this->assertEquals("element", $body[0]["points"][0][2]); + } + + /** + * @group tcp + */ + public function testQueryApiWithMultipleData() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + $this->object->mark("tcp.test", ["mark" => "element2"]); + $this->object->mark("tcp.test", ["mark" => "element3"]); + + $body = $this->object->query("select mark from tcp.test", "s"); + + $this->assertCount(3, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + } + + /** + * @group tcp + */ + public function testQueryApiWithTimePrecision() + { + $this->object->mark("tcp.test", ["mark" => "element"]); + + $body = $this->object->query("select mark from tcp.test", "s"); + + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + } + + /** + * @group tcp + */ + public function testWriteApiWithTimePrecision() + { + $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); + + $body = $this->object->query("select mark from tcp.test", "ms"); + + $this->assertCount(1, $body[0]["points"]); + $this->assertEquals("tcp.test", $body[0]["name"]); + + $this->assertEquals("1410591552000", $body[0]["points"][0][0]); + } + + public function testListActiveDatabses() + { + $databases = $this->object->getDatabases(); + + $this->assertCount(1, $databases); + } + + public function testCreateANewDatabase() + { + $this->object->createDatabase("walter"); + $databases = $this->object->getDatabases(); + + $this->assertCount(2, $databases); + + $this->object->deleteDatabase("walter"); + } +} From 162b61fe105e0fc1599df4cdc8dfb559a8c2dbbe Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Mon, 2 Mar 2015 20:58:00 +0100 Subject: [PATCH 059/158] Bumped version 0.3.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index abd410582..0d91a54c7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.4 +0.3.0 From 06ae666e4e6c0360b0c058ecd6e83e49987a8e37 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 20 Mar 2015 20:23:03 +0100 Subject: [PATCH 060/158] Fixes #14 - guzzle http json_decode -> assoc arrays --- spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php | 6 +++--- src/InfluxDB/Filter/ColumnsPointsFilter.php | 8 ++++---- tests/InfluxDB/ClientTest.php | 16 ++++++++++++++++ tests/InfluxDB/HttpAdapterTest.php | 16 ++++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php b/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php index 4e85f88fc..efe19eeb0 100644 --- a/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php +++ b/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php @@ -19,7 +19,7 @@ class ColumnsPointsFilterSpec extends ObjectBehavior function it_should_map_columns_with_points() { - $response = json_decode('[{"name":"hd_used","columns":["time","sequence_number","value","host","mount","time_precision"],"points":[[1410591684,11820001,23.2,"serverA","/mnt","s"]]}]'); + $response = json_decode('[{"name":"hd_used","columns":["time","sequence_number","value","host","mount","time_precision"],"points":[[1410591684,11820001,23.2,"serverA","/mnt","s"]]}]', true); $this->filter($response)->shouldBeEqualTo([ "hd_used" => [ @@ -37,7 +37,7 @@ class ColumnsPointsFilterSpec extends ObjectBehavior function it_should_map_also_a_series_list() { - $response = json_decode('[{"name":"list_series_result","columns":["time","name"],"points":[[0,"hd_used"]]}]'); + $response = json_decode('[{"name":"list_series_result","columns":["time","name"],"points":[[0,"hd_used"]]}]', true); $this->filter($response)->shouldBeEqualTo([ "list_series_result" => [ @@ -51,7 +51,7 @@ class ColumnsPointsFilterSpec extends ObjectBehavior function it_should_reply_to_an_empty_set() { - $response = json_decode('[]'); + $response = json_decode('[]', true); $this->filter($response)->shouldBeEqualTo([]); } diff --git a/src/InfluxDB/Filter/ColumnsPointsFilter.php b/src/InfluxDB/Filter/ColumnsPointsFilter.php index 54e9ff127..dcc974d39 100644 --- a/src/InfluxDB/Filter/ColumnsPointsFilter.php +++ b/src/InfluxDB/Filter/ColumnsPointsFilter.php @@ -15,11 +15,11 @@ class ColumnsPointsFilter implements FilterInterface $response = []; foreach ($metrics as $metric) { - $columns = $metric->columns; - $response[$metric->name] = []; + $columns = $metric["columns"]; + $response[$metric["name"]] = []; - foreach ($metric->points as $point) { - $response[$metric->name][] = array_combine($columns, $point); + foreach ($metric["points"] as $point) { + $response[$metric["name"]][] = array_combine($columns, $point); } } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 45ea0397e..2a4bf78ea 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -5,6 +5,7 @@ use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter; use InfluxDB\Options; use InfluxDB\Adapter\UdpAdapter; use GuzzleHttp\Client as GuzzleHttpClient; +use InfluxDB\Filter\ColumnsPointsFilter; class ClientTest extends \PHPUnit_Framework_TestCase { @@ -146,6 +147,21 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("udp.test", $body[0]["name"]); } + /** + * @group filter + */ + public function testColumnsPointsFilterWorksCorrectly() + { + $this->object->setFilter(new ColumnsPointsFilter()); + $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); + + $body = $this->object->query("select mark from tcp.test", "ms"); + + $this->assertCount(1, $body); + $this->assertEquals("element", $body["tcp.test"][0]["mark"]); + $this->assertSame(1410591552000, $body["tcp.test"][0]["time"]); + } + public function testListActiveDatabses() { $databases = $this->object->getDatabases(); diff --git a/tests/InfluxDB/HttpAdapterTest.php b/tests/InfluxDB/HttpAdapterTest.php index 9d6871c83..d6f868982 100644 --- a/tests/InfluxDB/HttpAdapterTest.php +++ b/tests/InfluxDB/HttpAdapterTest.php @@ -3,6 +3,7 @@ namespace InfluxDB; use InfluxDB\Adapter\HttpAdapter; use InfluxDB\Adapter\UdpAdapter; +use InfluxDB\Filter\ColumnsPointsFilter; class HttpAdapterTest extends \PHPUnit_Framework_TestCase { @@ -109,6 +110,21 @@ class HttpAdapterTest extends \PHPUnit_Framework_TestCase $this->assertEquals("1410591552000", $body[0]["points"][0][0]); } + /** + * @group filter + */ + public function testColumnsPointsFilterWorksCorrectly() + { + $this->object->setFilter(new ColumnsPointsFilter()); + $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); + + $body = $this->object->query("select mark from tcp.test", "ms"); + + $this->assertCount(1, $body); + $this->assertEquals("element", $body["tcp.test"][0]["mark"]); + $this->assertSame(1410591552000, $body["tcp.test"][0]["time"]); + } + public function testListActiveDatabses() { $databases = $this->object->getDatabases(); From 704ea74277db30ba308eea56dd1671195f10d2bc Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 20 Mar 2015 20:47:33 +0100 Subject: [PATCH 061/158] Bumped version 0.3.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0d91a54c7..9e11b32fc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.0 +0.3.1 From e125b296f99f1abd6c57b1a52e37306a1128082b Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Mon, 23 Mar 2015 21:42:54 +0100 Subject: [PATCH 062/158] phpunit configuration improvement This feature implement env parameters for phpUnit configuration. This upgrade is a first step for multi influxdb version testing --- phpunit.xml.dist | 12 ++++++++++++ tests/bootstrap.php | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ada74cb23..2b12f4ecb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,6 +12,18 @@ tests + + + + + + + + + + + + src diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 99b776def..4f2e9ae33 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,18 +1,18 @@ [ - "host" => "localhost", - "port" => 8086, - "protocol" => "http", - "database" => "tcp.test", - "username" => "root", - "password" => "root", + "host" => getenv('HOST'), + "port" => getenv('TCP_PORT'), + "protocol" => getenv('TCP_PROTOCOL'), + "database" => getenv('TCP_DB'), + "username" => getenv('USERNAME'), + "password" => getenv('PASSWORD'), ], "udp" => [ - "host" => "localhost", - "port" => 5551, - "database" => "udp.test", - "username" => "root", - "password" => "root" + "host" => getenv('HOST'), + "port" => getenv('UDP_PORT'), + "database" => getenv('UDP_DB'), + "username" => getenv('USERNAME'), + "password" => getenv('PASSWORD'), ], ]; From 16197e22a94d8cdf5ddb25437f8551b8aff1fb46 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 24 Mar 2015 08:30:55 +0100 Subject: [PATCH 063/158] Contributing doc file --- CONTRIBUTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..7af948a1a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing to InfluxDB PHP SDK + +## Pull requests are always welcome + +Not sure if that typo is worth a pull request? Found a bug and know how to fix +it? Do it! We will appreciate it. Any significant improvement should be +documented as a GitHub issue before anybody starts working on it. + +We are always thrilled to receive pull requests. We do our best to process them +quickly. If your pull request is not accepted on the first try, don't get +discouraged! + +We follows the *vincent driessen's branching model* +[http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/) + From 4140300e328b626dde43980a05f863229bbff278 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 8 Apr 2015 19:21:51 +0200 Subject: [PATCH 064/158] Files should end with a newline character --- src/InfluxDB/Adapter/HttpAdapter.php | 3 ++- src/InfluxDB/Exception/InfluxAuthorizationException.php | 3 ++- src/InfluxDB/Exception/InfluxBadResponseException.php | 3 ++- src/InfluxDB/Exception/InfluxGeneralException.php | 3 ++- src/InfluxDB/Exception/InfluxNoSeriesException.php | 3 ++- src/InfluxDB/Exception/InfluxUnexpectedResponseException.php | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/InfluxDB/Adapter/HttpAdapter.php b/src/InfluxDB/Adapter/HttpAdapter.php index 738f43c83..691b3b6d3 100644 --- a/src/InfluxDB/Adapter/HttpAdapter.php +++ b/src/InfluxDB/Adapter/HttpAdapter.php @@ -195,4 +195,5 @@ class HttpAdapter implements AdapterInterface, QueryableInterface } return $this->parseResponse($response); } -} \ No newline at end of file +} + diff --git a/src/InfluxDB/Exception/InfluxAuthorizationException.php b/src/InfluxDB/Exception/InfluxAuthorizationException.php index f4feb823f..83dcd32c7 100644 --- a/src/InfluxDB/Exception/InfluxAuthorizationException.php +++ b/src/InfluxDB/Exception/InfluxAuthorizationException.php @@ -5,4 +5,5 @@ namespace InfluxDB\Exception; class InfluxAuthorizationException extends InfluxGeneralException { -} \ No newline at end of file +} + diff --git a/src/InfluxDB/Exception/InfluxBadResponseException.php b/src/InfluxDB/Exception/InfluxBadResponseException.php index fc693200a..148dada20 100644 --- a/src/InfluxDB/Exception/InfluxBadResponseException.php +++ b/src/InfluxDB/Exception/InfluxBadResponseException.php @@ -5,4 +5,5 @@ namespace InfluxDB\Exception; class InfluxBadResponseException extends InfluxGeneralException { -} \ No newline at end of file +} + diff --git a/src/InfluxDB/Exception/InfluxGeneralException.php b/src/InfluxDB/Exception/InfluxGeneralException.php index 145947369..863095db8 100644 --- a/src/InfluxDB/Exception/InfluxGeneralException.php +++ b/src/InfluxDB/Exception/InfluxGeneralException.php @@ -5,4 +5,5 @@ namespace InfluxDB\Exception; class InfluxGeneralException extends \RuntimeException { -} \ No newline at end of file +} + diff --git a/src/InfluxDB/Exception/InfluxNoSeriesException.php b/src/InfluxDB/Exception/InfluxNoSeriesException.php index 117d6ccb8..39306690f 100644 --- a/src/InfluxDB/Exception/InfluxNoSeriesException.php +++ b/src/InfluxDB/Exception/InfluxNoSeriesException.php @@ -5,4 +5,5 @@ namespace InfluxDB\Exception; class InfluxNoSeriesException extends InfluxGeneralException { -} \ No newline at end of file +} + diff --git a/src/InfluxDB/Exception/InfluxUnexpectedResponseException.php b/src/InfluxDB/Exception/InfluxUnexpectedResponseException.php index 3d1ceae50..f7416c9a8 100644 --- a/src/InfluxDB/Exception/InfluxUnexpectedResponseException.php +++ b/src/InfluxDB/Exception/InfluxUnexpectedResponseException.php @@ -5,4 +5,5 @@ namespace InfluxDB\Exception; class InfluxUnexpectedResponseException extends InfluxGeneralException { -} \ No newline at end of file +} + From 4fa3ad0efa79e3ebeed9c376639b323342d51680 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 8 Apr 2015 19:25:00 +0200 Subject: [PATCH 065/158] Bumped version 0.3.2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9e11b32fc..d15723fbe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.1 +0.3.2 From e369530539fd1a146486dfe11b46d598eb321468 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Thu, 7 May 2015 14:51:26 +0200 Subject: [PATCH 066/158] Remove filters --- README.md | 51 +--------------- spec/InfluxDB/ClientSpec.php | 12 ---- .../Filter/ColumnsPointsFilterSpec.php | 58 ------------------- src/InfluxDB/Client.php | 29 ---------- src/InfluxDB/ClientFactory.php | 8 --- src/InfluxDB/Filter/ColumnsPointsFilter.php | 28 --------- src/InfluxDB/Filter/FilterInterface.php | 14 ----- tests/InfluxDB/ClientFactoryTest.php | 18 ------ tests/InfluxDB/ClientTest.php | 16 ----- tests/InfluxDB/HttpAdapterTest.php | 15 ----- 10 files changed, 1 insertion(+), 248 deletions(-) delete mode 100644 spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php delete mode 100644 src/InfluxDB/Filter/ColumnsPointsFilter.php delete mode 100644 src/InfluxDB/Filter/FilterInterface.php diff --git a/README.md b/README.md index ac7051628..5d766d332 100644 --- a/README.md +++ b/README.md @@ -114,12 +114,7 @@ $options = [ ], "options" => [ "host" => "my.influx.domain.tld", - ], - "filters" => [ - "query" => [ - "name" => "InfluxDB\\Filter\\ColumnsPointsFilter" - ], - ], + ] ]; $client = \InfluxDB\ClientFactory::create($options); @@ -187,30 +182,6 @@ array(1) { } ``` -By default data is returned as is. You can add filters in order to change a -response as you prefer, by default this library carries a common filter that -simplifies the response. - -``` -$client->setFilter(new ColumnsPointsFilter()); - -$data = $client->query("select * from hd_used"); -``` - -With the "ColumnsPointsFilter" you get a list of dictionaries, something like: - -``` -[ - "serie_name" => [ - [ - "time" => 410545635590, - "sequence_number" => 390001, - "mark" => "element", - ], - ] -] -``` - ## Database operations You can create, list or destroy databases using dedicated methods @@ -237,23 +208,3 @@ Corley\Benchmarks\InfluxDB\AdapterEvent sendDataUsingHttpAdapter: [1,000 ] [0.0026700308323] [374.52751] sendDataUsingUdpAdapter : [1,000 ] [0.0000436344147] [22,917.69026] ``` - -### Filters - -Just what append when you apply the `ColumnsPointsFilter` - -``` -Corley\Benchmarks\InfluxDB\FilterEvent - Method Name Iterations Average Time Ops/second - ------------------------ ------------ -------------- ------------- - get10PointDirectData : [10,000 ] [0.0001383633137] [7,227.34931] - get10PointFilteredData : [10,000 ] [0.0001662570953] [6,014.78089] - get100PointDirectData : [1,000 ] [0.0002406690121] [4,155.08416] - get100PointFilteredData : [1,000 ] [0.0008374640942] [1,194.08104] - get1000PointDirectData : [100 ] [0.0011058974266] [904.24299] - get1000PointFilteredData: [100 ] [0.0074790692329] [133.70648] -``` - -in order to eliminate the http handshake and bandwidth overhead network -operations are completely skipped - diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php index 126ac4f05..84e5753db 100644 --- a/spec/InfluxDB/ClientSpec.php +++ b/spec/InfluxDB/ClientSpec.php @@ -6,7 +6,6 @@ use Prophecy\Argument; use InfluxDB\Adapter\GuzzleAdapter; use InfluxDB\Adapter\UdpAdapter; use InfluxDB\Adapter\AdapterInterface; -use InfluxDB\Filter\FilterInterface; use InfluxDb\Adapter\QueryableInterface; class ClientSpec extends ObjectBehavior @@ -84,15 +83,4 @@ class ClientSpec extends ObjectBehavior $this->shouldThrow("\\BadMethodCallException")->duringQuery("select * from tcp.test"); } - - function it_should_filter_returned_data(FilterInterface $filter, QueryableInterface $adapter) - { - $adapter->query(Argument::Any(), Argument::Any())->willReturn(null); - $filter->filter(Argument::Any())->shouldBeCalledTimes(1)->willReturn([]); - - $this->setFilter($filter); - $this->setAdapter($adapter); - - $this->query("select * from tcp.test")->shouldReturn([]); - } } diff --git a/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php b/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php deleted file mode 100644 index efe19eeb0..000000000 --- a/spec/InfluxDB/Filter/ColumnsPointsFilterSpec.php +++ /dev/null @@ -1,58 +0,0 @@ -shouldHaveType('InfluxDB\Filter\ColumnsPointsFilter'); - } - - function it_is_a_valid_filter() - { - $this->shouldImplement("InfluxDb\\Filter\\FilterInterface"); - } - - function it_should_map_columns_with_points() - { - $response = json_decode('[{"name":"hd_used","columns":["time","sequence_number","value","host","mount","time_precision"],"points":[[1410591684,11820001,23.2,"serverA","/mnt","s"]]}]', true); - - $this->filter($response)->shouldBeEqualTo([ - "hd_used" => [ - [ - "time" => 1410591684, - "sequence_number" => 11820001, - "value" => 23.2, - "host" => "serverA", - "mount" => "/mnt", - "time_precision" => "s", - ], - ], - ]); - } - - function it_should_map_also_a_series_list() - { - $response = json_decode('[{"name":"list_series_result","columns":["time","name"],"points":[[0,"hd_used"]]}]', true); - - $this->filter($response)->shouldBeEqualTo([ - "list_series_result" => [ - [ - "time" => 0, - "name" => "hd_used", - ], - ], - ]); - } - - function it_should_reply_to_an_empty_set() - { - $response = json_decode('[]', true); - - $this->filter($response)->shouldBeEqualTo([]); - } -} diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index b7215244f..8baa37d4a 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -15,31 +15,6 @@ class Client */ private $adapter; - /** - * @var \InfluxDB\Filter\FilterInterface - */ - private $filter; - - /** - * Set filter - * @param Filter\FilterInterface $filter - * @return Client - */ - public function setFilter(Filter\FilterInterface $filter) - { - $this->filter = $filter; - return $this; - } - - /** - * Get filter - * @return Filter\FilterInterface - */ - public function getFilter() - { - return $this->filter; - } - /** * Set InfluxDB adapter * @param Adapter\AdapterInterface @@ -96,10 +71,6 @@ class Client $return = $this->getAdapter()->query($query, $timePrecision); - if ($this->getFilter() instanceOf FilterInterface) { - $return = $this->getFilter()->filter($return); - } - return $return; } diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php index a466cfc54..9fdeb4d25 100644 --- a/src/InfluxDB/ClientFactory.php +++ b/src/InfluxDB/ClientFactory.php @@ -14,7 +14,6 @@ abstract class ClientFactory * @param array $options * @return Client * @throws InvalidArgumentException If not exist adapter name - * or not find adapter */ public static function create(array $options) { @@ -24,9 +23,6 @@ abstract class ClientFactory "options" => [], ], "options" => [], - "filters" => [ - "query" => false - ], ]; $options = array_replace_recursive($defaultOptions, $options); @@ -58,10 +54,6 @@ abstract class ClientFactory $client = new Client(); $client->setAdapter($adapter); - if ($options["filters"]["query"]) { - $client->setFilter(new $options["filters"]["query"]["name"]); - } - return $client; } } diff --git a/src/InfluxDB/Filter/ColumnsPointsFilter.php b/src/InfluxDB/Filter/ColumnsPointsFilter.php deleted file mode 100644 index dcc974d39..000000000 --- a/src/InfluxDB/Filter/ColumnsPointsFilter.php +++ /dev/null @@ -1,28 +0,0 @@ - ["name" => "InfluxDB\\Adapter\\GuzzleAdapter"]]); - - $this->assertNull($client->getFilter()); - } - /** * @group factory * @expectedException InvalidArgumentException @@ -95,7 +85,6 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase /** * @group factory - * @group filters * @dataProvider getTcpAdapters */ public function testCreateTcpClientWithFilter($adapter) @@ -109,11 +98,6 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase "username" => "user", "password" => "pass", ], - "filters" => [ - "query" => [ - "name" => "InfluxDB\\Filter\\ColumnsPointsFilter", - ], - ], ]; $client = ClientFactory::create($options); @@ -123,7 +107,5 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); - - $this->assertInstanceOf("InfluxDB\\Filter\\ColumnsPointsFilter", $client->getFilter()); } } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 2a4bf78ea..45ea0397e 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -5,7 +5,6 @@ use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter; use InfluxDB\Options; use InfluxDB\Adapter\UdpAdapter; use GuzzleHttp\Client as GuzzleHttpClient; -use InfluxDB\Filter\ColumnsPointsFilter; class ClientTest extends \PHPUnit_Framework_TestCase { @@ -147,21 +146,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("udp.test", $body[0]["name"]); } - /** - * @group filter - */ - public function testColumnsPointsFilterWorksCorrectly() - { - $this->object->setFilter(new ColumnsPointsFilter()); - $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); - - $body = $this->object->query("select mark from tcp.test", "ms"); - - $this->assertCount(1, $body); - $this->assertEquals("element", $body["tcp.test"][0]["mark"]); - $this->assertSame(1410591552000, $body["tcp.test"][0]["time"]); - } - public function testListActiveDatabses() { $databases = $this->object->getDatabases(); diff --git a/tests/InfluxDB/HttpAdapterTest.php b/tests/InfluxDB/HttpAdapterTest.php index d6f868982..9cd2fca8f 100644 --- a/tests/InfluxDB/HttpAdapterTest.php +++ b/tests/InfluxDB/HttpAdapterTest.php @@ -110,21 +110,6 @@ class HttpAdapterTest extends \PHPUnit_Framework_TestCase $this->assertEquals("1410591552000", $body[0]["points"][0][0]); } - /** - * @group filter - */ - public function testColumnsPointsFilterWorksCorrectly() - { - $this->object->setFilter(new ColumnsPointsFilter()); - $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); - - $body = $this->object->query("select mark from tcp.test", "ms"); - - $this->assertCount(1, $body); - $this->assertEquals("element", $body["tcp.test"][0]["mark"]); - $this->assertSame(1410591552000, $body["tcp.test"][0]["time"]); - } - public function testListActiveDatabses() { $databases = $this->object->getDatabases(); From 8481e780547db81677932580a223d815fb3673d5 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Mon, 18 May 2015 19:14:33 +0200 Subject: [PATCH 067/158] Composer improvement Guzzle 5 --- composer.json | 2 +- composer.lock | 734 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 500 insertions(+), 236 deletions(-) diff --git a/composer.json b/composer.json index 729eaa9d9..7c8c2331e 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "license": "MIT", "description": "Send your app metrics to InfluxDB", "require": { - "guzzlehttp/guzzle": "~4", + "guzzlehttp/guzzle": "~4|~5", "zendframework/zend-stdlib": "~2", "zendframework/zend-filter": "~2", "zendframework/zend-servicemanager": "~2" diff --git a/composer.lock b/composer.lock index aebf066d2..7a6d24902 100644 --- a/composer.lock +++ b/composer.lock @@ -4,25 +4,24 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "b8984634251cdc10c12d585b63e98fbd", + "hash": "43d7cf570f8cc52b5210875b97760120", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "4.2.3", + "version": "5.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "66fd916e9f9130bc22c51450476823391cb2f67c" + "reference": "475b29ccd411f2fa8a408e64576418728c032cfa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd916e9f9130bc22c51450476823391cb2f67c", - "reference": "66fd916e9f9130bc22c51450476823391cb2f67c", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/475b29ccd411f2fa8a408e64576418728c032cfa", + "reference": "475b29ccd411f2fa8a408e64576418728c032cfa", "shasum": "" }, "require": { - "ext-json": "*", - "guzzlehttp/streams": "~2.1", + "guzzlehttp/ringphp": "~1.0", "php": ">=5.4.0" }, "require-dev": { @@ -30,22 +29,16 @@ "phpunit/phpunit": "~4.0", "psr/log": "~1.0" }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "5.0-dev" } }, "autoload": { "psr-4": { "GuzzleHttp\\": "src/" - }, - "files": [ - "src/functions.php" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -69,41 +62,44 @@ "rest", "web service" ], - "time": "2014-10-05 19:29:14" + "time": "2015-01-28 01:03:29" }, { - "name": "guzzlehttp/streams", - "version": "2.1.0", + "name": "guzzlehttp/ringphp", + "version": "1.0.7", "source": { "type": "git", - "url": "https://github.com/guzzle/streams.git", - "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534" + "url": "https://github.com/guzzle/RingPHP.git", + "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/streams/zipball/f91b721d73f0e561410903b3b3c90a5d0e40b534", - "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534", + "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/52d868f13570a9a56e5fce6614e0ec75d0f13ac2", + "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2", "shasum": "" }, "require": { - "php": ">=5.4.0" + "guzzlehttp/streams": "~3.0", + "php": ">=5.4.0", + "react/promise": "~2.0" }, "require-dev": { + "ext-curl": "*", "phpunit/phpunit": "~4.0" }, + "suggest": { + "ext-curl": "Guzzle will use specific adapters if cURL is present" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { "psr-4": { - "GuzzleHttp\\Stream\\": "src/" - }, - "files": [ - "src/functions.php" - ] + "GuzzleHttp\\Ring\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -116,27 +112,115 @@ "homepage": "https://github.com/mtdowling" } ], - "description": "Provides a simple abstraction over streams of data (Guzzle 4+)", + "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", + "time": "2015-03-30 01:43:20" + }, + { + "name": "guzzlehttp/streams", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/streams.git", + "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", + "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Provides a simple abstraction over streams of data", "homepage": "http://guzzlephp.org/", "keywords": [ "Guzzle", "stream" ], - "time": "2014-08-17 21:15:53" + "time": "2014-10-12 19:18:40" }, { - "name": "zendframework/zend-filter", - "version": "2.3.3", - "target-dir": "Zend/Filter", + "name": "react/promise", + "version": "v2.2.0", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendFilter.git", - "reference": "98b8c2abfdc9009e4c0157e78c9f22bf2cebb693" + "url": "https://github.com/reactphp/promise.git", + "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendFilter/zipball/98b8c2abfdc9009e4c0157e78c9f22bf2cebb693", - "reference": "98b8c2abfdc9009e4c0157e78c9f22bf2cebb693", + "url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef", + "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "React\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@googlemail.com" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "time": "2014-12-30 13:32:42" + }, + { + "name": "zendframework/zend-filter", + "version": "2.4.2", + "source": { + "type": "git", + "url": "https://github.com/zendframework/zend-filter.git", + "reference": "a3711101850078b2aa69586c71897acaada2e9cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/a3711101850078b2aa69586c71897acaada2e9cb", + "reference": "a3711101850078b2aa69586c71897acaada2e9cb", "shasum": "" }, "require": { @@ -144,6 +228,9 @@ "zendframework/zend-stdlib": "self.version" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-crypt": "self.version", "zendframework/zend-servicemanager": "self.version", "zendframework/zend-uri": "self.version" @@ -157,13 +244,13 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } }, "autoload": { - "psr-0": { - "Zend\\Filter\\": "" + "psr-4": { + "Zend\\Filter\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -171,110 +258,117 @@ "BSD-3-Clause" ], "description": "provides a set of commonly needed data filters", - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-filter", "keywords": [ "filter", "zf2" ], - "time": "2014-09-16 22:58:11" + "time": "2015-05-07 14:55:31" }, { "name": "zendframework/zend-servicemanager", - "version": "2.3.3", - "target-dir": "Zend/ServiceManager", + "version": "2.4.2", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendServiceManager.git", - "reference": "559403e4fd10db2516641f20f129a568d7e6a993" + "url": "https://github.com/zendframework/zend-servicemanager.git", + "reference": "855294e12771b4295c26446b6ed2df2f1785f234" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendServiceManager/zipball/559403e4fd10db2516641f20f129a568d7e6a993", - "reference": "559403e4fd10db2516641f20f129a568d7e6a993", + "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/855294e12771b4295c26446b6ed2df2f1785f234", + "reference": "855294e12771b4295c26446b6ed2df2f1785f234", "shasum": "" }, "require": { "php": ">=5.3.23" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-di": "self.version" }, "suggest": { + "ocramius/proxy-manager": "ProxyManager 0.5.* to handle lazy initialization of services", "zendframework/zend-di": "Zend\\Di component" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } }, "autoload": { - "psr-0": { - "Zend\\ServiceManager\\": "" + "psr-4": { + "Zend\\ServiceManager\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-service-manager", "keywords": [ "servicemanager", "zf2" ], - "time": "2014-09-16 22:58:11" + "time": "2015-05-07 14:55:31" }, { "name": "zendframework/zend-stdlib", - "version": "2.3.3", - "target-dir": "Zend/Stdlib", + "version": "2.4.2", "source": { "type": "git", - "url": "https://github.com/zendframework/Component_ZendStdlib.git", - "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33" + "url": "https://github.com/zendframework/zend-stdlib.git", + "reference": "a5dd7fd2ba6e8f6c6ea5a12db0605d3aa48af1e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", - "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", + "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/a5dd7fd2ba6e8f6c6ea5a12db0605d3aa48af1e7", + "reference": "a5dd7fd2ba6e8f6c6ea5a12db0605d3aa48af1e7", "shasum": "" }, "require": { "php": ">=5.3.23" }, "require-dev": { + "fabpot/php-cs-fixer": "1.7.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-filter": "self.version", "zendframework/zend-serializer": "self.version", "zendframework/zend-servicemanager": "self.version" }, "suggest": { "zendframework/zend-eventmanager": "To support aggregate hydrator usage", + "zendframework/zend-filter": "To support naming strategy hydrator usage", "zendframework/zend-serializer": "Zend\\Serializer component", "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev", - "dev-develop": "2.4-dev" + "dev-master": "2.4-dev", + "dev-develop": "2.5-dev" } }, "autoload": { - "psr-0": { - "Zend\\Stdlib\\": "" + "psr-4": { + "Zend\\Stdlib\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zf2", + "homepage": "https://github.com/zendframework/zend-stdlib", "keywords": [ "stdlib", "zf2" ], - "time": "2014-09-16 22:58:11" + "time": "2015-05-07 14:55:31" } ], "packages-dev": [ @@ -479,27 +573,27 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "38743b677965c48a637097b2746a281264ae2347" + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/38743b677965c48a637097b2746a281264ae2347", - "reference": "38743b677965c48a637097b2746a281264ae2347", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "3.7.*@stable" + "phpunit/phpunit": "~4.0" }, "suggest": { - "dflydev/markdown": "1.0.*", - "erusev/parsedown": "~0.7" + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" }, "type": "library", "extra": { @@ -524,7 +618,7 @@ "email": "mike.vanriel@naenius.com" } ], - "time": "2014-08-09 10:27:07" + "time": "2015-02-03 12:10:50" }, { "name": "phpspec/php-diff", @@ -562,31 +656,36 @@ }, { "name": "phpspec/phpspec", - "version": "2.0.1", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpspec/phpspec.git", - "reference": "61712147412cb647b6cb68b19833a60bfda759a1" + "reference": "9727d75919a00455433e867565bc022f0b985a39" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/phpspec/zipball/61712147412cb647b6cb68b19833a60bfda759a1", - "reference": "61712147412cb647b6cb68b19833a60bfda759a1", + "url": "https://api.github.com/repos/phpspec/phpspec/zipball/9727d75919a00455433e867565bc022f0b985a39", + "reference": "9727d75919a00455433e867565bc022f0b985a39", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.0.1", "php": ">=5.3.3", "phpspec/php-diff": "~1.0.0", - "phpspec/prophecy": "~1.1", - "symfony/console": "~2.1", + "phpspec/prophecy": "~1.4", + "sebastian/exporter": "~1.0", + "symfony/console": "~2.3", "symfony/event-dispatcher": "~2.1", "symfony/finder": "~2.1", + "symfony/process": "~2.1", "symfony/yaml": "~2.1" }, "require-dev": { - "behat/behat": "~2.5", - "bossa/phpspec2-expect": "dev-master", - "symfony/filesystem": "~2.1" + "behat/behat": "^3.0.11", + "bossa/phpspec2-expect": "~1.0", + "phpunit/phpunit": "~4.4", + "symfony/filesystem": "~2.1", + "symfony/process": "~2.1" }, "suggest": { "phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters" @@ -597,7 +696,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.2.x-dev" } }, "autoload": { @@ -631,25 +730,26 @@ "testing", "tests" ], - "time": "2014-07-01 14:09:19" + "time": "2015-04-18 16:22:51" }, { "name": "phpspec/prophecy", - "version": "v1.3.1", + "version": "v1.4.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "9ca52329bcdd1500de24427542577ebf3fc2f1c9" + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/9ca52329bcdd1500de24427542577ebf3fc2f1c9", - "reference": "9ca52329bcdd1500de24427542577ebf3fc2f1c9", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", "shasum": "" }, "require": { - "doctrine/instantiator": "~1.0,>=1.0.2", - "phpdocumentor/reflection-docblock": "~2.0" + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" }, "require-dev": { "phpspec/phpspec": "~2.0" @@ -657,7 +757,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { @@ -681,7 +781,7 @@ } ], "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "http://phpspec.org", + "homepage": "https://github.com/phpspec/prophecy", "keywords": [ "Double", "Dummy", @@ -690,20 +790,20 @@ "spy", "stub" ], - "time": "2014-11-17 16:23:49" + "time": "2015-04-27 22:15:08" }, { "name": "phpunit/php-code-coverage", - "version": "2.0.11", + "version": "2.0.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7" + "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7", - "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c", + "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c", "shasum": "" }, "require": { @@ -716,7 +816,7 @@ }, "require-dev": { "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4.1" + "phpunit/phpunit": "~4" }, "suggest": { "ext-dom": "*", @@ -735,9 +835,6 @@ ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -755,35 +852,37 @@ "testing", "xunit" ], - "time": "2014-08-31 06:33:04" + "time": "2015-04-11 04:35:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.3.4", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, "autoload": { "classmap": [ - "File/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -800,7 +899,7 @@ "filesystem", "iterator" ], - "time": "2013-10-10 15:34:57" + "time": "2015-04-02 05:19:05" }, { "name": "phpunit/php-text-template", @@ -892,16 +991,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.3.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" + "reference": "eab81d02569310739373308137284e0158424330" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330", + "reference": "eab81d02569310739373308137284e0158424330", "shasum": "" }, "require": { @@ -914,7 +1013,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -937,20 +1036,20 @@ "keywords": [ "tokenizer" ], - "time": "2014-08-31 06:12:13" + "time": "2015-04-08 04:46:07" }, { "name": "phpunit/phpunit", - "version": "4.3.5", + "version": "4.6.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1" + "reference": "3afe303d873a4d64c62ef84de491b97b006fbdac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2dab9d593997db4abcf58d0daf798eb4e9cecfe1", - "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3afe303d873a4d64c62ef84de491b97b006fbdac", + "reference": "3afe303d873a4d64c62ef84de491b97b006fbdac", "shasum": "" }, "require": { @@ -960,17 +1059,19 @@ "ext-reflection": "*", "ext-spl": "*", "php": ">=5.3.3", - "phpunit/php-code-coverage": "~2.0", - "phpunit/php-file-iterator": "~1.3.2", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.0,>=2.0.11", + "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0.2", + "phpunit/php-timer": "~1.0", "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.0", - "sebastian/diff": "~1.1", - "sebastian/environment": "~1.0", - "sebastian/exporter": "~1.0", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", "sebastian/version": "~1.0", - "symfony/yaml": "~2.0" + "symfony/yaml": "~2.1|~3.0" }, "suggest": { "phpunit/php-invoker": "~1.1" @@ -981,7 +1082,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3.x-dev" + "dev-master": "4.6.x-dev" } }, "autoload": { @@ -990,10 +1091,6 @@ ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "", - "../../symfony/yaml/" - ], "license": [ "BSD-3-Clause" ], @@ -1005,35 +1102,35 @@ } ], "description": "The PHP Unit Testing framework.", - "homepage": "http://www.phpunit.de/", + "homepage": "https://phpunit.de/", "keywords": [ "phpunit", "testing", "xunit" ], - "time": "2014-11-11 10:11:09" + "time": "2015-04-29 15:18:52" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.0", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "c63d2367247365f688544f0d500af90a11a44c65" + "reference": "74ffb87f527f24616f72460e54b595f508dccb5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", - "reference": "c63d2367247365f688544f0d500af90a11a44c65", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c", + "reference": "74ffb87f527f24616f72460e54b595f508dccb5c", "shasum": "" }, "require": { - "doctrine/instantiator": "~1.0,>=1.0.1", + "doctrine/instantiator": "~1.0,>=1.0.2", "php": ">=5.3.3", "phpunit/php-text-template": "~1.2" }, "require-dev": { - "phpunit/phpunit": "~4.3" + "phpunit/phpunit": "~4.4" }, "suggest": { "ext-soap": "*" @@ -1066,7 +1163,7 @@ "mock", "xunit" ], - "time": "2014-10-03 05:12:11" + "time": "2015-04-02 05:36:41" }, { "name": "pimple/pimple", @@ -1116,30 +1213,30 @@ }, { "name": "sebastian/comparator", - "version": "1.0.1", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef" + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", - "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", "shasum": "" }, "require": { "php": ">=5.3.3", - "sebastian/diff": "~1.1", - "sebastian/exporter": "~1.0" + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" }, "require-dev": { - "phpunit/phpunit": "~4.1" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -1176,20 +1273,20 @@ "compare", "equality" ], - "time": "2014-05-11 23:00:21" + "time": "2015-01-29 16:28:08" }, { "name": "sebastian/diff", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", "shasum": "" }, "require": { @@ -1201,7 +1298,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -1228,32 +1325,32 @@ "keywords": [ "diff" ], - "time": "2014-08-15 10:29:00" + "time": "2015-02-22 15:13:53" }, { "name": "sebastian/environment", - "version": "1.2.0", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d" + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d", - "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.3" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -1278,32 +1375,33 @@ "environment", "hhvm" ], - "time": "2014-10-22 06:38:05" + "time": "2015-01-01 10:01:08" }, { "name": "sebastian/exporter", - "version": "1.0.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0" + "reference": "84839970d05254c73cde183a721c7af13aede943" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", - "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -1343,20 +1441,124 @@ "export", "exporter" ], - "time": "2014-09-10 00:51:36" + "time": "2015-01-27 07:23:06" }, { - "name": "sebastian/version", - "version": "1.0.3", + "name": "sebastian/global-state", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", - "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", "shasum": "" }, "type": "library", @@ -1378,21 +1580,21 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2014-03-07 15:35:33" + "time": "2015-02-24 06:35:25" }, { "name": "symfony/console", - "version": "v2.5.6", + "version": "v2.6.7", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "6f177fca24200a5b97aef5ce7a5c98124a0f0db0" + "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/6f177fca24200a5b97aef5ce7a5c98124a0f0db0", - "reference": "6f177fca24200a5b97aef5ce7a5c98124a0f0db0", + "url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272", + "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272", "shasum": "" }, "require": { @@ -1400,16 +1602,19 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1" + "symfony/event-dispatcher": "~2.1", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.1" }, "suggest": { "psr/log": "For using the console logger", - "symfony/event-dispatcher": "" + "symfony/event-dispatcher": "", + "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -1422,32 +1627,32 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Console Component", - "homepage": "http://symfony.com", - "time": "2014-10-05 13:57:04" + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" }, { "name": "symfony/event-dispatcher", - "version": "v2.5.6", + "version": "v2.6.7", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "804eb28dbbfba9ffdab21fe2066744906cea2212" + "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/804eb28dbbfba9ffdab21fe2066744906cea2212", - "reference": "804eb28dbbfba9ffdab21fe2066744906cea2212", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02", + "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02", "shasum": "" }, "require": { @@ -1455,9 +1660,11 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.0,<2.6.0", - "symfony/stopwatch": "~2.2" + "symfony/config": "~2.0,>=2.0.5", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/stopwatch": "~2.3" }, "suggest": { "symfony/dependency-injection": "", @@ -1466,7 +1673,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -1479,41 +1686,44 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2014-10-01 15:43:05" + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" }, { "name": "symfony/finder", - "version": "v2.5.6", + "version": "v2.6.7", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "cf66df4e783e6aade319b273c9bcf9e42aa9b10f" + "reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/cf66df4e783e6aade319b273c9bcf9e42aa9b10f", - "reference": "cf66df4e783e6aade319b273c9bcf9e42aa9b10f", + "url": "https://api.github.com/repos/symfony/Finder/zipball/704c64c8b12c8882640d5c0330a8414b1e06dc99", + "reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" } }, "autoload": { @@ -1526,41 +1736,94 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Finder Component", - "homepage": "http://symfony.com", - "time": "2014-10-01 05:50:18" + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" }, { - "name": "symfony/yaml", - "version": "v2.5.6", - "target-dir": "Symfony/Component/Yaml", + "name": "symfony/process", + "version": "v2.6.7", + "target-dir": "Symfony/Component/Process", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726" + "url": "https://github.com/symfony/Process.git", + "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/2d9f527449cabfa8543dd7fa3a466d6ae83d6726", - "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726", + "url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", + "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Process\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" + }, + { + "name": "symfony/yaml", + "version": "v2.6.7", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" } }, "autoload": { @@ -1573,18 +1836,18 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2014-10-01 05:50:18" + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" }, { "name": "zeptech/annotations", @@ -1631,6 +1894,7 @@ "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, + "prefer-lowest": false, "platform": [], "platform-dev": { "ext-sockets": "*" From d677fa94d4a3a2ffff5fadcc20c1a08bda444469 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Mon, 18 May 2015 20:51:43 +0200 Subject: [PATCH 068/158] Dump release 0.3.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d15723fbe..1c09c74e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.2 +0.3.3 From 46333360ea4b08ebf664c48228683bc2edd09dd2 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Thu, 7 May 2015 15:17:18 +0200 Subject: [PATCH 069/158] Add explicit PHP version into composer.json --- composer.json | 1 + composer.lock | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 7c8c2331e..c04e461c5 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,7 @@ "license": "MIT", "description": "Send your app metrics to InfluxDB", "require": { + "php": ">=5.4", "guzzlehttp/guzzle": "~4|~5", "zendframework/zend-stdlib": "~2", "zendframework/zend-filter": "~2", diff --git a/composer.lock b/composer.lock index 7a6d24902..596fdd473 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "43d7cf570f8cc52b5210875b97760120", + "hash": "f2dbbf00b528de2e350ff4550629e1b4", "packages": [ { "name": "guzzlehttp/guzzle", @@ -1170,12 +1170,12 @@ "version": "v2.1.1", "source": { "type": "git", - "url": "https://github.com/fabpot/Pimple.git", + "url": "https://github.com/silexphp/Pimple.git", "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Pimple/zipball/ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", "shasum": "" }, @@ -1895,7 +1895,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=5.4" + }, "platform-dev": { "ext-sockets": "*" } From 37da8604f14acccbbacb69d4ec33b1c8cbeba8bd Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 4 Jun 2015 13:14:38 +0200 Subject: [PATCH 070/158] Restore HTTP adapter for InfluxDB 0.9 --- composer.json | 1 - composer.lock | 479 ++++---------------- phpunit.xml.dist | 2 +- spec/InfluxDB/Adapter/GuzzleAdapterSpec.php | 90 ---- spec/InfluxDB/Adapter/HttpAdapterSpec.php | 194 -------- spec/InfluxDB/Adapter/UdpAdapterSpec.php | 25 - spec/InfluxDB/ClientSpec.php | 86 ---- spec/InfluxDB/OptionsSpec.php | 40 -- src/InfluxDB/Adapter/GuzzleAdapter.php | 20 +- src/InfluxDB/Client.php | 10 +- src/InfluxDB/Options.php | 13 +- tests/InfluxDB/ClientTest.php | 17 +- tests/InfluxDB/HttpAdapterTest.php | 2 + 13 files changed, 111 insertions(+), 868 deletions(-) delete mode 100644 spec/InfluxDB/Adapter/GuzzleAdapterSpec.php delete mode 100755 spec/InfluxDB/Adapter/HttpAdapterSpec.php delete mode 100644 spec/InfluxDB/Adapter/UdpAdapterSpec.php delete mode 100644 spec/InfluxDB/ClientSpec.php delete mode 100644 spec/InfluxDB/OptionsSpec.php diff --git a/composer.json b/composer.json index c04e461c5..0ba459dba 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,6 @@ "zendframework/zend-servicemanager": "~2" }, "require-dev": { - "phpspec/phpspec": "2.*", "phpunit/phpunit": "4.*", "athletic/athletic": "~0.1", "ext-sockets": "*" diff --git a/composer.lock b/composer.lock index 596fdd473..805bb9737 100644 --- a/composer.lock +++ b/composer.lock @@ -4,30 +4,30 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f2dbbf00b528de2e350ff4550629e1b4", + "hash": "96faa156d58fde5c5c3cf3df60d74ae1", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "5.2.0", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "475b29ccd411f2fa8a408e64576418728c032cfa" + "reference": "f3c8c22471cb55475105c14769644a49c3262b93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/475b29ccd411f2fa8a408e64576418728c032cfa", - "reference": "475b29ccd411f2fa8a408e64576418728c032cfa", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93", + "reference": "f3c8c22471cb55475105c14769644a49c3262b93", "shasum": "" }, "require": { - "guzzlehttp/ringphp": "~1.0", + "guzzlehttp/ringphp": "^1.1", "php": ">=5.4.0" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" }, "type": "library", "extra": { @@ -62,20 +62,20 @@ "rest", "web service" ], - "time": "2015-01-28 01:03:29" + "time": "2015-05-20 03:47:55" }, { "name": "guzzlehttp/ringphp", - "version": "1.0.7", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/RingPHP.git", - "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2" + "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/52d868f13570a9a56e5fce6614e0ec75d0f13ac2", - "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2", + "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", + "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", "shasum": "" }, "require": { @@ -93,7 +93,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1-dev" } }, "autoload": { @@ -113,7 +113,7 @@ } ], "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", - "time": "2015-03-30 01:43:20" + "time": "2015-05-20 03:37:09" }, { "name": "guzzlehttp/streams", @@ -211,29 +211,31 @@ }, { "name": "zendframework/zend-filter", - "version": "2.4.2", + "version": "2.5.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-filter.git", - "reference": "a3711101850078b2aa69586c71897acaada2e9cb" + "reference": "93e6990a198e6cdd811064083acac4693f4b29ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/a3711101850078b2aa69586c71897acaada2e9cb", - "reference": "a3711101850078b2aa69586c71897acaada2e9cb", + "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/93e6990a198e6cdd811064083acac4693f4b29ae", + "reference": "93e6990a198e6cdd811064083acac4693f4b29ae", "shasum": "" }, "require": { "php": ">=5.3.23", - "zendframework/zend-stdlib": "self.version" + "zendframework/zend-stdlib": "~2.5" }, "require-dev": { "fabpot/php-cs-fixer": "1.7.*", "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "dev-master", - "zendframework/zend-crypt": "self.version", - "zendframework/zend-servicemanager": "self.version", - "zendframework/zend-uri": "self.version" + "zendframework/zend-config": "~2.5", + "zendframework/zend-crypt": "~2.5", + "zendframework/zend-i18n": "~2.5", + "zendframework/zend-loader": "~2.5", + "zendframework/zend-servicemanager": "~2.5", + "zendframework/zend-uri": "~2.5" }, "suggest": { "zendframework/zend-crypt": "Zend\\Crypt component", @@ -244,8 +246,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev", - "dev-develop": "2.5-dev" + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" } }, "autoload": { @@ -263,20 +265,20 @@ "filter", "zf2" ], - "time": "2015-05-07 14:55:31" + "time": "2015-06-03 15:32:01" }, { "name": "zendframework/zend-servicemanager", - "version": "2.4.2", + "version": "2.5.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-servicemanager.git", - "reference": "855294e12771b4295c26446b6ed2df2f1785f234" + "reference": "3b22c403e351d92526c642cba0bd810bc22e1c56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/855294e12771b4295c26446b6ed2df2f1785f234", - "reference": "855294e12771b4295c26446b6ed2df2f1785f234", + "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/3b22c403e351d92526c642cba0bd810bc22e1c56", + "reference": "3b22c403e351d92526c642cba0bd810bc22e1c56", "shasum": "" }, "require": { @@ -285,8 +287,8 @@ "require-dev": { "fabpot/php-cs-fixer": "1.7.*", "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "dev-master", - "zendframework/zend-di": "self.version" + "zendframework/zend-di": "~2.5", + "zendframework/zend-mvc": "~2.5" }, "suggest": { "ocramius/proxy-manager": "ProxyManager 0.5.* to handle lazy initialization of services", @@ -295,8 +297,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev", - "dev-develop": "2.5-dev" + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" } }, "autoload": { @@ -308,25 +310,25 @@ "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-service-manager", + "homepage": "https://github.com/zendframework/zend-servicemanager", "keywords": [ "servicemanager", "zf2" ], - "time": "2015-05-07 14:55:31" + "time": "2015-06-03 15:32:02" }, { "name": "zendframework/zend-stdlib", - "version": "2.4.2", + "version": "2.5.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "a5dd7fd2ba6e8f6c6ea5a12db0605d3aa48af1e7" + "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/a5dd7fd2ba6e8f6c6ea5a12db0605d3aa48af1e7", - "reference": "a5dd7fd2ba6e8f6c6ea5a12db0605d3aa48af1e7", + "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cc8e90a60dd5d44b9730b77d07b97550091da1ae", + "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae", "shasum": "" }, "require": { @@ -335,11 +337,12 @@ "require-dev": { "fabpot/php-cs-fixer": "1.7.*", "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "dev-master", - "zendframework/zend-eventmanager": "self.version", - "zendframework/zend-filter": "self.version", - "zendframework/zend-serializer": "self.version", - "zendframework/zend-servicemanager": "self.version" + "zendframework/zend-config": "~2.5", + "zendframework/zend-eventmanager": "~2.5", + "zendframework/zend-filter": "~2.5", + "zendframework/zend-inputfilter": "~2.5", + "zendframework/zend-serializer": "~2.5", + "zendframework/zend-servicemanager": "~2.5" }, "suggest": { "zendframework/zend-eventmanager": "To support aggregate hydrator usage", @@ -350,8 +353,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev", - "dev-develop": "2.5-dev" + "dev-master": "2.5-dev", + "dev-develop": "2.6-dev" } }, "autoload": { @@ -368,7 +371,7 @@ "stdlib", "zf2" ], - "time": "2015-05-07 14:55:31" + "time": "2015-06-03 15:32:03" } ], "packages-dev": [ @@ -620,118 +623,6 @@ ], "time": "2015-02-03 12:10:50" }, - { - "name": "phpspec/php-diff", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/phpspec/php-diff.git", - "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a", - "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-0": { - "Diff": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Chris Boulton", - "homepage": "http://github.com/chrisboulton", - "role": "Original developer" - } - ], - "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", - "time": "2013-11-01 13:02:21" - }, - { - "name": "phpspec/phpspec", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/phpspec.git", - "reference": "9727d75919a00455433e867565bc022f0b985a39" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/phpspec/zipball/9727d75919a00455433e867565bc022f0b985a39", - "reference": "9727d75919a00455433e867565bc022f0b985a39", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.1", - "php": ">=5.3.3", - "phpspec/php-diff": "~1.0.0", - "phpspec/prophecy": "~1.4", - "sebastian/exporter": "~1.0", - "symfony/console": "~2.3", - "symfony/event-dispatcher": "~2.1", - "symfony/finder": "~2.1", - "symfony/process": "~2.1", - "symfony/yaml": "~2.1" - }, - "require-dev": { - "behat/behat": "^3.0.11", - "bossa/phpspec2-expect": "~1.0", - "phpunit/phpunit": "~4.4", - "symfony/filesystem": "~2.1", - "symfony/process": "~2.1" - }, - "suggest": { - "phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters" - }, - "bin": [ - "bin/phpspec" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "psr-0": { - "PhpSpec": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "homepage": "http://marcelloduarte.net/" - } - ], - "description": "Specification-oriented BDD framework for PHP 5.3+", - "homepage": "http://phpspec.net/", - "keywords": [ - "BDD", - "SpecBDD", - "TDD", - "spec", - "specification", - "testing", - "tests" - ], - "time": "2015-04-18 16:22:51" - }, { "name": "phpspec/prophecy", "version": "v1.4.1", @@ -794,16 +685,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.0.16", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c" + "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c", - "reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/28a6b34e91d789b2608072ab3c82eaae7cdb973c", + "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c", "shasum": "" }, "require": { @@ -826,7 +717,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "2.1.x-dev" } }, "autoload": { @@ -852,7 +743,7 @@ "testing", "xunit" ], - "time": "2015-04-11 04:35:00" + "time": "2015-06-03 07:01:01" }, { "name": "phpunit/php-file-iterator", @@ -1040,16 +931,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.6.6", + "version": "4.6.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3afe303d873a4d64c62ef84de491b97b006fbdac" + "reference": "7b5fe98b28302a8b25693b2298bca74463336975" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3afe303d873a4d64c62ef84de491b97b006fbdac", - "reference": "3afe303d873a4d64c62ef84de491b97b006fbdac", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7b5fe98b28302a8b25693b2298bca74463336975", + "reference": "7b5fe98b28302a8b25693b2298bca74463336975", "shasum": "" }, "require": { @@ -1108,20 +999,20 @@ "testing", "xunit" ], - "time": "2015-04-29 15:18:52" + "time": "2015-06-03 05:03:30" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.1", + "version": "2.3.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "74ffb87f527f24616f72460e54b595f508dccb5c" + "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c", - "reference": "74ffb87f527f24616f72460e54b595f508dccb5c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7", + "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7", "shasum": "" }, "require": { @@ -1163,7 +1054,7 @@ "mock", "xunit" ], - "time": "2015-04-02 05:36:41" + "time": "2015-05-29 05:19:18" }, { "name": "pimple/pimple", @@ -1582,240 +1473,22 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2015-02-24 06:35:25" }, - { - "name": "symfony/console", - "version": "v2.6.7", - "target-dir": "Symfony/Component/Console", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272", - "reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.1" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.6.7", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02", - "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", - "symfony/stopwatch": "~2.3" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" - }, - { - "name": "symfony/finder", - "version": "v2.6.7", - "target-dir": "Symfony/Component/Finder", - "source": { - "type": "git", - "url": "https://github.com/symfony/Finder.git", - "reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/704c64c8b12c8882640d5c0330a8414b1e06dc99", - "reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Finder\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" - }, - { - "name": "symfony/process", - "version": "v2.6.7", - "target-dir": "Symfony/Component/Process", - "source": { - "type": "git", - "url": "https://github.com/symfony/Process.git", - "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", - "reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Process\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" - }, { "name": "symfony/yaml", - "version": "v2.6.7", - "target-dir": "Symfony/Component/Yaml", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2" + "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2", - "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3", + "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9" }, "require-dev": { "symfony/phpunit-bridge": "~2.7" @@ -1823,11 +1496,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.7-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Yaml\\": "" } }, @@ -1847,7 +1520,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:18:45" + "time": "2015-05-02 15:21:08" }, { "name": "zeptech/annotations", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2b12f4ecb..445587fb6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,7 +13,7 @@ - + diff --git a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php b/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php deleted file mode 100644 index 815fa87a7..000000000 --- a/spec/InfluxDB/Adapter/GuzzleAdapterSpec.php +++ /dev/null @@ -1,90 +0,0 @@ -getHttpSeriesEndpoint()->willReturn("localhost"); - $options->getHttpDatabaseEndpoint()->willReturn("localhost"); - $options->getUsername()->willReturn("one"); - $options->getPassword()->willReturn("two"); - $this->beConstructedWith($client, $options); - } - - function it_is_initializable() - { - $this->shouldHaveType('InfluxDB\Adapter\GuzzleAdapter'); - } - - function it_should_send_data_via_post(Client $client, Options $options) - { - $client->post("localhost", [ - 'auth' => ["one", "two"], - 'body' => json_encode(['pippo']) - ])->shouldBeCalledTimes(1); - - $this->send(["pippo"]); - } - - function it_should_query_data(Client $client, Options $options) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "query" => [ - "q" => "select * from tcp.test", - ] - ] - )->willReturn(new Response(200,[],null)); - $this->query("select * from tcp.test")->shouldReturn(null); - } - - function it_should_query_data_with_time_precision(Client $client, Options $options) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "query" => [ - "time_precision" => "s", - "q" => "select * from tcp.test", - ] - ] - )->willReturn(new Response(200, [], null)); - $this->query("select * from tcp.test", "s")->shouldReturn(null); - } - - function it_should_list_all_databases(Client $client, Options $options) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"] - ] - )->shouldBeCalledTimes(1)->willReturn(new Response(200, [], null)); - - $this->getDatabases()->shouldReturn(null); - } - - function it_should_create_a_new_database(Client $client, Options $options) - { - $client->post( - "localhost", - [ - "auth" => ["one", "two"], - "body" => json_encode(["name" => "db_name"]) - ] - )->shouldBeCalledTimes(1)->willReturn(new Response(200, [], null)); - - $this->createDatabase("db_name")->shouldReturn(null); - } -} diff --git a/spec/InfluxDB/Adapter/HttpAdapterSpec.php b/spec/InfluxDB/Adapter/HttpAdapterSpec.php deleted file mode 100755 index fac255668..000000000 --- a/spec/InfluxDB/Adapter/HttpAdapterSpec.php +++ /dev/null @@ -1,194 +0,0 @@ -shouldHaveType('InfluxDB\Adapter\HttpAdapter'); - } - - function let(Options $options, Client $client) - { - $options->getHttpSeriesEndpoint()->willReturn("localhost"); - $options->getHttpDatabaseEndpoint()->willReturn("localhost"); - $options->getUsername()->willReturn("one"); - $options->getPassword()->willReturn("two"); - $this->beConstructedWith($options, $client); - } - - function it_should_send_data_via_post(Client $client) - { - $responseBody = ['key'=>'value']; - $response = new Response(200,[], Stream::factory(json_encode($responseBody))); - $client->post("localhost", [ - 'auth' => ["one", "two"], - 'exceptions' => false, - 'body' => json_encode(['pippo']) - ])->willReturn($response) - ->shouldBeCalledTimes(1); - $this->send(["pippo"])->shouldReturn($responseBody); - } - - function it_should_query_data(Client $client, Options $options) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "exceptions" => false, - "query" => [ - "q" => "select * from tcp.test", - ] - ] - )->willReturn(new Response(200,[],null)); - $this->query("select * from tcp.test")->shouldReturn(null); - } - - function it_should_query_data_with_time_precision(Client $client, Options $options) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "exceptions" => false, - "query" => [ - "time_precision" => "s", - "q" => "select * from tcp.test", - ] - ] - )->willReturn(new Response(200, [], null)); - $this->query("select * from tcp.test", "s")->shouldReturn(null); - } - - function it_should_list_all_databases(Client $client, Options $options) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "exceptions" => false, - ] - )->shouldBeCalledTimes(1)->willReturn(new Response(200, [], null)); - - $this->getDatabases()->shouldReturn(null); - } - - function it_should_create_a_new_database(Client $client, Options $options) - { - $client->post( - "localhost", - [ - "auth" => ["one", "two"], - "exceptions" => false, - "body" => json_encode(["name" => "db_name"]) - ] - )->shouldBeCalledTimes(1)->willReturn(new Response(201, [], null)); - - $this->createDatabase("db_name")->shouldReturn(true); - } - - function it_should_return_true_with_success(Client $client) { - foreach ([201,204,299] as $code) { - $client->post(Argument::any(), Argument::any(), Argument::any())->willReturn(new Response($code, [], null)); - - $this->createDatabase("db_name")->shouldReturn(true); - } - } - - - - function it_should_throw_no_series_exception (Client $client) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "exceptions" => false, - "query" => [ - "q" => "select * from tcp.test", - ] - ] - )->willReturn(new Response(HttpAdapter::STATUS_CODE_BAD_REQUEST,[], Stream::factory("Couldn't find series: tcp.test"))); - $this->shouldThrow(new InfluxNoSeriesException("Couldn't find series: tcp.test", HttpAdapter::STATUS_CODE_BAD_REQUEST)) - ->during("query", ["select * from tcp.test"]); - } - - function it_should_throw_authorization_exception (Client $client) - { - $codes = [HttpAdapter::STATUS_CODE_UNAUTHORIZED, HttpAdapter::STATUS_CODE_FORBIDDEN]; - foreach ($codes as $code) { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "exceptions" => false, - "query" => [ - "q" => "select * from tcp.test", - ] - ] - )->willReturn(new Response($code,[], Stream::factory("Message"))); - $this->shouldThrow(new InfluxAuthorizationException("Message", $code)) - ->during("query", ["select * from tcp.test"]); - } - } - - function it_should_throw_general_exception (Client $client) - { - $client->get( - "localhost", - [ - "auth" => ["one", "two"], - "exceptions" => false, - "query" => [ - "q" => "select * from tcp.test", - ] - ] - )->willReturn(new Response(409,[], Stream::factory("Message"))); - $this->shouldThrow(new InfluxGeneralException("Message", 409)) - ->during("query", ["select * from tcp.test"]); - } - - function it_should_throw_general_exception_with_default_message (Client $client) - { - $client->get(Argument::any(), Argument::any())->willReturn(new Response(409)); - $this->shouldThrow(new InfluxGeneralException("Conflict", 409)) - ->during("query", ["select * from tcp.test"]); - } - - function it_should_throw_bad_response_exception(Client $client) - { - $response = new Response(200,[], Stream::factory('bad response')); - $client->post("localhost", [ - 'auth' => ["one", "two"], - 'exceptions' => false, - 'body' => json_encode(['pippo']) - ])->willReturn($response) - ->shouldBeCalledTimes(1); - $this->shouldThrow(new InfluxBadResponseException("Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON; Response is 'bad response'", 0)) - ->during("send", [["pippo"]]); - } - - function it_should_throw_unexpected_response_exception (Client $client) - { - foreach ([0, 300, 500] as $code) { - $client->get(Argument::any(), Argument::any())->willReturn(new Response($code, [], Stream::factory("Message"))); - $this->shouldThrow(new InfluxUnexpectedResponseException("Message", $code)) - ->during("query", ["select * from tcp.test"]); - } - } -} diff --git a/spec/InfluxDB/Adapter/UdpAdapterSpec.php b/spec/InfluxDB/Adapter/UdpAdapterSpec.php deleted file mode 100644 index 48e14198f..000000000 --- a/spec/InfluxDB/Adapter/UdpAdapterSpec.php +++ /dev/null @@ -1,25 +0,0 @@ -beConstructedWith($options); - } - - function it_is_initializable() - { - $this->shouldHaveType('InfluxDB\Adapter\UdpAdapter'); - } - - function it_should_implement_adapter_interface() - { - $this->shouldImplement("InfluxDB\Adapter\AdapterInterface"); - } -} diff --git a/spec/InfluxDB/ClientSpec.php b/spec/InfluxDB/ClientSpec.php deleted file mode 100644 index 84e5753db..000000000 --- a/spec/InfluxDB/ClientSpec.php +++ /dev/null @@ -1,86 +0,0 @@ -setAdapter($adapter); - } - - function it_is_initializable() - { - $this->shouldHaveType('InfluxDB\Client'); - } - - function it_should_send_data(AdapterInterface $adapter) - { - $adapter->send([[ - "name" => "video.search", - "columns" => ["author", "title"], - "points" => [ - ["Guccini", "Autogrill"] - ] - ]], false)->shouldBeCalledTimes(1); - - $this->mark("video.search", [ - "author" => "Guccini", - "title" => "Autogrill" - ]); - } - - function it_should_send_data_with_time_precision(AdapterInterface $adapter) - { - $adapter->send([[ - "name" => "video.search", - "columns" => ["time", "author", "title"], - "points" => [ - ["1410591552", "Guccini", "Autogrill"] - ] - ]], "s")->shouldBeCalledTimes(1); - - $this->mark("video.search", [ - "time" => "1410591552", - "author" => "Guccini", - "title" => "Autogrill" - ], "s"); - } - - function it_should_query_on_querable_adapter(GuzzleAdapter $adapter) - { - $this->setAdapter($adapter); - $adapter->query("select * from tcp.test", false)->willReturn([]); - - $this->query("select * from tcp.test")->shouldReturn([]); - } - - function it_should_query_with_time_precision(GuzzleAdapter $adapter) - { - $this->setAdapter($adapter); - $adapter->query("select * from tcp.test", "s")->willReturn([]); - - $this->query("select * from tcp.test", "s")->shouldReturn([]); - } - - function it_should_query_but_skip_invalid_time_precision(GuzzleAdapter $adapter) - { - $this->setAdapter($adapter); - $adapter->query("select * from tcp.test", false)->willReturn([]); - - $this->query("select * from tcp.test", "r")->shouldReturn([]); - } - - function it_should_thrown_an_exception_on_unquerable_adapter(UdpAdapter $adapter) - { - $this->setAdapter($adapter); - - $this->shouldThrow("\\BadMethodCallException")->duringQuery("select * from tcp.test"); - } -} diff --git a/spec/InfluxDB/OptionsSpec.php b/spec/InfluxDB/OptionsSpec.php deleted file mode 100644 index d926faf83..000000000 --- a/spec/InfluxDB/OptionsSpec.php +++ /dev/null @@ -1,40 +0,0 @@ -shouldHaveType('InfluxDB\Options'); - } - - function it_should_create_a_valid_tcp_endpoint() - { - $this->setDatabase("mine"); - $this->getHttpSeriesEndpoint() - ->shouldReturn("http://localhost:8086/db/mine/series"); - } - - function it_should_allows_option_override_for_tcp_endpoint() - { - $this->setHost("influx.1.prod.tld"); - $this->setPort(19385); - $this->setUsername("walter"); - $this->setPassword("walter"); - $this->setDatabase("me"); - $this->getHttpSeriesEndpoint() - ->shouldReturn("http://influx.1.prod.tld:19385/db/me/series"); - } - - function it_should_allows_https_for_tcp_endpoint() - { - $this->setProtocol("https"); - $this->setDatabase("me"); - $this->getHttpSeriesEndpoint() - ->shouldReturn("https://localhost:8086/db/me/series"); - } -} diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index f8fe908fc..ee60dc123 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -67,6 +67,7 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface "auth" => [$this->options->getUsername(), $this->options->getPassword()], 'query' => [ "q" => $query, + "db" => $this->getOptions()->getDatabase(), ] ]; @@ -74,7 +75,7 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface $options["query"]["time_precision"] = $timePrecision; } - $endpoint = $this->options->getHttpSeriesEndpoint(); + $endpoint = $this->options->getHttpQueryEndpoint(); return $this->httpClient->get($endpoint, $options)->json(); } @@ -86,10 +87,12 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface { $options = [ "auth" => [$this->options->getUsername(), $this->options->getPassword()], + "query" => [ + "q" => "show databases", + ], ]; - $endpoint = $this->options->getHttpDatabaseEndpoint(); - + $endpoint = $this->options->getHttpQueryEndpoint(); return $this->httpClient->get($endpoint, $options)->json(); } @@ -100,11 +103,11 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface { $httpMessage = [ "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "body" => json_encode(["name" => $name]) + "query" => ["q" => "CREATE DATABASE \"{$name}\""], ]; - $endpoint = $this->options->getHttpDatabaseEndpoint(); - return $this->httpClient->post($endpoint, $httpMessage)->json(); + $endpoint = $this->options->getHttpQueryEndpoint(); + return $this->httpClient->get($endpoint, $httpMessage)->json(); } /** @@ -114,9 +117,10 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface { $httpMessage = [ "auth" => [$this->options->getUsername(), $this->options->getPassword()], + "query" => ["q" => "drop database \"{$name}\""], ]; - $endpoint = $this->options->getHttpDatabaseEndpoint($name); - return $this->httpClient->delete($endpoint, $httpMessage)->json(); + $endpoint = $this->options->getHttpQueryEndpoint(); + return $this->httpClient->get($endpoint, $httpMessage)->json(); } } diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 8baa37d4a..b06909f7f 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -42,17 +42,17 @@ class Client * @param bool|string $timePrecision * @return mixed */ - public function mark($name, array $values, $timePrecision = false) + public function mark($name, array $values = [], $timePrecision = false) { $data =[]; $timePrecision = $this->clearTimePrecision($timePrecision); - $data['name'] = $name; - $data['columns'] = array_keys($values); - $data['points'][] = array_values($values); + $data["database"] = $this->getAdapter()->getOptions()->getDatabase(); + $data['points'][0]['name'] = $name; + $data['points'][0]['fields'] = $values; - return $this->getAdapter()->send([$data], $timePrecision); + return $this->getAdapter()->send($data, $timePrecision); } /** diff --git a/src/InfluxDB/Options.php b/src/InfluxDB/Options.php index ef1344ec4..16f157fd0 100644 --- a/src/InfluxDB/Options.php +++ b/src/InfluxDB/Options.php @@ -160,11 +160,10 @@ class Options public function getHttpSeriesEndpoint() { return sprintf( - "%s://%s:%d/db/%s/series", + "%s://%s:%d/write", $this->getProtocol(), $this->getHost(), - $this->getPort(), - $this->getDatabase() + $this->getPort() ); } @@ -173,19 +172,15 @@ class Options * @param string $name * @return string */ - public function getHttpDatabaseEndpoint($name = false) + public function getHttpQueryEndpoint($name = false) { $url = sprintf( - "%s://%s:%d/db", + "%s://%s:%d/query", $this->getProtocol(), $this->getHost(), $this->getPort() ); - if ($name !== false) { - $url .= "/{$name}"; - } - return $url; } } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 45ea0397e..1e1a16ba5 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -38,8 +38,10 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->object = $influx; $databases = $this->object->getDatabases(); - foreach ($databases as $database) { - $this->object->deleteDatabase($database["name"]); + if (array_key_exists("values", $databases["results"][0]["series"][0])) { + foreach ($databases["results"][0]["series"][0]["values"] as $database) { + $this->object->deleteDatabase($database[0]); + } } $this->object->createDatabase($this->rawOptions["udp"]["database"]); @@ -51,11 +53,14 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testGuzzleHttpApiWorksCorrectly() { - $this->object->mark("tcp.test", ["mark" => "element"]); + $t = $this->object->mark("tcp.test", ["mark" => "element"]); - $body = $this->object->query("select * from tcp.test"); - $this->assertCount(1, $body[0]["points"]); - $this->assertEquals("element", $body[0]["points"][0][2]); + sleep(1); + + $body = $this->object->query("select * from \"tcp.test\""); + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } /** diff --git a/tests/InfluxDB/HttpAdapterTest.php b/tests/InfluxDB/HttpAdapterTest.php index 9cd2fca8f..b7e1a4c4a 100644 --- a/tests/InfluxDB/HttpAdapterTest.php +++ b/tests/InfluxDB/HttpAdapterTest.php @@ -13,6 +13,8 @@ class HttpAdapterTest extends \PHPUnit_Framework_TestCase public function setUp() { + $this->markTestSkipped(); + $options = include __DIR__ . '/../bootstrap.php'; $this->rawOptions = $options; From fd28135fe3bb1827452b4ff0ca33a7ca42d715ed Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 12:31:11 +0200 Subject: [PATCH 071/158] Restore base behavior --- src/InfluxDB/Adapter/GuzzleAdapter.php | 15 +- src/InfluxDB/Adapter/HttpAdapter.php | 199 ------------------------- src/InfluxDB/Client.php | 55 +------ src/InfluxDB/ClientFactory.php | 3 - tests/InfluxDB/ClientFactoryTest.php | 1 - tests/InfluxDB/ClientTest.php | 51 ++++--- tests/InfluxDB/HttpAdapterTest.php | 131 ---------------- 7 files changed, 50 insertions(+), 405 deletions(-) delete mode 100644 src/InfluxDB/Adapter/HttpAdapter.php delete mode 100644 tests/InfluxDB/HttpAdapterTest.php diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index ee60dc123..2ebbceed1 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -75,9 +75,7 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface $options["query"]["time_precision"] = $timePrecision; } - $endpoint = $this->options->getHttpQueryEndpoint(); - - return $this->httpClient->get($endpoint, $options)->json(); + return $this->get($options); } /** @@ -92,8 +90,7 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface ], ]; - $endpoint = $this->options->getHttpQueryEndpoint(); - return $this->httpClient->get($endpoint, $options)->json(); + return $this->get($options); } /** @@ -106,8 +103,7 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface "query" => ["q" => "CREATE DATABASE \"{$name}\""], ]; - $endpoint = $this->options->getHttpQueryEndpoint(); - return $this->httpClient->get($endpoint, $httpMessage)->json(); + return $this->get($httpMessage); } /** @@ -120,6 +116,11 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface "query" => ["q" => "drop database \"{$name}\""], ]; + return $this->get($httpMessage); + } + + private function get(array $httpMessage) + { $endpoint = $this->options->getHttpQueryEndpoint(); return $this->httpClient->get($endpoint, $httpMessage)->json(); } diff --git a/src/InfluxDB/Adapter/HttpAdapter.php b/src/InfluxDB/Adapter/HttpAdapter.php deleted file mode 100644 index 691b3b6d3..000000000 --- a/src/InfluxDB/Adapter/HttpAdapter.php +++ /dev/null @@ -1,199 +0,0 @@ -options = $options; - $this->client = $client ?: new Client(); - } - - /** - * @return Options - */ - public function getOptions() - { - return $this->options; - } - - /** - * @param array $body - * @param array $query - * @param bool $timePrecision - * @return array - */ - protected function getRequest(array $body = [], array $query = [], $timePrecision = false) - { - $request = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "exceptions" => false - ]; - if (count($body)) { - $request['body'] = json_encode($body); - } - if (count($query)) { - $request['query'] = $query; - } - if ($timePrecision) { - $request["query"]["time_precision"] = $timePrecision; - } - return $request; - } - - /** - * @param ResponseInterface $response - * @return mixed - * @throws \InfluxDB\Exception\InfluxGeneralException - * @throws \InfluxDB\Exception\InfluxAuthorizationException - * @throws \InfluxDB\Exception\InfluxNoSeriesException - */ - protected function parseResponse(ResponseInterface $response) - { - $statusCode = $response->getStatusCode(); - if ($statusCode >= 400 && $statusCode < 500) { - $message = (string)$response->getBody(); - if (!$message) { - $message = $response->getReasonPhrase(); - } - switch ($statusCode) { - case self::STATUS_CODE_UNAUTHORIZED: - case self::STATUS_CODE_FORBIDDEN: - throw new InfluxAuthorizationException($message, $statusCode); - case self::STATUS_CODE_BAD_REQUEST: - if (strpos($message, "Couldn't find series:") !== false) { - throw new InfluxNoSeriesException($message, $statusCode); - } - } - throw new InfluxGeneralException($message, $statusCode); - } else if ($statusCode == self::STATUS_CODE_OK) { - try { - return $response->json(); - } catch (ParseException $ex) { - throw new InfluxBadResponseException( - sprintf("%s; Response is '%s'", $ex->getMessage(), (string)$response->getBody()), - $ex->getCode(), $ex - ); - } - } else if ($statusCode > 200 && $statusCode < 300) { - return true; - } - throw new InfluxUnexpectedResponseException((string)$response->getBody(), $statusCode); - } - - /** - * @param $message - * @param bool $timePrecision - * @return \GuzzleHttp\Message\ResponseInterface - */ - public function send($message, $timePrecision = false) - { - try { - $response = $this->client->post( - $this->options->getHttpSeriesEndpoint(), - $this->getRequest($message, [], $timePrecision) - ); - } catch (\Exception $ex) { - throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); - } - return $this->parseResponse($response); - } - - /** - * @param $query - * @param bool $timePrecision - * @return mixed - */ - public function query($query, $timePrecision = false) - { - try { - $response = $this->client->get( - $this->options->getHttpSeriesEndpoint(), - $this->getRequest([], ["q" => $query], $timePrecision) - ); - } catch (\Exception $ex) { - throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); - } - return $this->parseResponse($response); - } - - /** - * @return mixed - */ - public function getDatabases() - { - try { - $response = $this->client->get( - $this->options->getHttpDatabaseEndpoint(), - $this->getRequest() - ); - } catch (\Exception $ex) { - throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); - } - return $this->parseResponse($response); - } - - /** - * @param $name - * @return mixed - */ - public function createDatabase($name) - { - try { - $response = $this->client->post( - $this->options->getHttpDatabaseEndpoint(), - $this->getRequest(["name" => $name]) - ); - } catch (\Exception $ex) { - throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); - } - return $this->parseResponse($response); - } - - /** - * @param $name - * @return mixed - */ - public function deleteDatabase($name) - { - try { - $response = $this->client->delete( - $this->options->getHttpDatabaseEndpoint($name), - $this->getRequest() - ); - } catch (\Exception $ex) { - throw new InfluxGeneralException($ex->getMessage(), $ex->getCode(), $ex); - } - return $this->parseResponse($response); - } -} - diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index b06909f7f..63603133a 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -10,57 +10,35 @@ use InfluxDB\Filter\FilterInterface; */ class Client { - /** - * @var \InfluxDB\Adapter\AdapterInterface - */ private $adapter; - /** - * Set InfluxDB adapter - * @param Adapter\AdapterInterface - * @return Client - */ public function setAdapter(Adapter\AdapterInterface $adapter) { $this->adapter = $adapter; return $this; } - /** - * Get adapter - * @return Adapter\AdapterInterface - */ public function getAdapter() { return $this->adapter; } - /** - * Insert point into series - * @param string $name - * @param array $value - * @param bool|string $timePrecision - * @return mixed - */ public function mark($name, array $values = [], $timePrecision = false) { - $data =[]; + $data = $name; + if (!is_array($name)) { + $data =[]; - $timePrecision = $this->clearTimePrecision($timePrecision); + $timePrecision = $this->clearTimePrecision($timePrecision); - $data["database"] = $this->getAdapter()->getOptions()->getDatabase(); - $data['points'][0]['name'] = $name; - $data['points'][0]['fields'] = $values; + $data["database"] = $this->getAdapter()->getOptions()->getDatabase(); + $data['points'][0]['name'] = $name; + $data['points'][0]['fields'] = $values; + } return $this->getAdapter()->send($data, $timePrecision); } - /** - * Make a query into database - * @param string $query - * @param bool|string $timePrecision - * @return array - */ public function query($query, $timePrecision = false) { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -74,10 +52,6 @@ class Client return $return; } - /** - * List of databases - * @return array - */ public function getDatabases() { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -86,10 +60,6 @@ class Client return $this->getAdapter()->getDatabases(); } - /** - * Create database by name - * @param string $name - */ public function createDatabase($name) { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -98,10 +68,6 @@ class Client return $this->getAdapter()->createDatabase($name); } - /** - * Delete database by name - * @param string $name - */ public function deleteDatabase($name) { if (!($this->getAdapter() instanceOf QueryableInterface)) { @@ -110,11 +76,6 @@ class Client return $this->getAdapter()->deleteDatabase($name); } - /** - * List of time precision choose - * @param string $timePrecision - * @return bool|string - */ private function clearTimePrecision($timePrecision) { switch ($timePrecision) { diff --git a/src/InfluxDB/ClientFactory.php b/src/InfluxDB/ClientFactory.php index 9fdeb4d25..a9ea2dccb 100644 --- a/src/InfluxDB/ClientFactory.php +++ b/src/InfluxDB/ClientFactory.php @@ -44,9 +44,6 @@ abstract class ClientFactory case 'InfluxDB\\Adapter\\GuzzleAdapter': $adapter = new $adapterName(new GuzzleClient($options["adapter"]["options"]), $adapterOptions); break; - case 'InfluxDB\\Adapter\\HttpAdapter': - $adapter = new $adapterName($adapterOptions, new GuzzleClient($options["adapter"]["options"])); - break; default: throw new \InvalidArgumentException("Missing adapter {$adapter}"); } diff --git a/tests/InfluxDB/ClientFactoryTest.php b/tests/InfluxDB/ClientFactoryTest.php index 8b4b9fea1..6d61c8960 100644 --- a/tests/InfluxDB/ClientFactoryTest.php +++ b/tests/InfluxDB/ClientFactoryTest.php @@ -79,7 +79,6 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase { return [ ["InfluxDB\\Adapter\\GuzzleAdapter"], - ["InfluxDB\\Adapter\\HttpAdapter"], ]; } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 1e1a16ba5..c569c420a 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -70,11 +70,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase { $this->object->mark("tcp.test", ["mark" => "element"]); - $body = $this->object->query("select * from tcp.test"); + sleep(1); - $this->assertCount(1, $body); - $this->assertEquals("tcp.test", $body[0]["name"]); - $this->assertEquals("element", $body[0]["points"][0][2]); + $body = $this->object->query("select * from \"tcp.test\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } /** @@ -86,10 +88,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->object->mark("tcp.test", ["mark" => "element2"]); $this->object->mark("tcp.test", ["mark" => "element3"]); - $body = $this->object->query("select mark from tcp.test", "s"); + sleep(1); - $this->assertCount(3, $body[0]["points"]); - $this->assertEquals("tcp.test", $body[0]["name"]); + $body = $this->object->query("select mark from \"tcp.test\"", "s"); + + $this->assertCount(3, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } /** @@ -97,12 +102,16 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testGuzzleHttpQueryApiWithTimePrecision() { + $this->markTestSkipped("Skip time precision"); $this->object->mark("tcp.test", ["mark" => "element"]); - $body = $this->object->query("select mark from tcp.test", "s"); + sleep(1); - $this->assertCount(1, $body[0]["points"]); - $this->assertEquals("tcp.test", $body[0]["name"]); + $body = $this->object->query("select mark from \"tcp.test\"", "s"); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } /** @@ -110,9 +119,12 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testGuzzleHttpWriteApiWithTimePrecision() { + $this->markTestSkipped("Skip time precision"); $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); - $body = $this->object->query("select mark from tcp.test", "ms"); + sleep(1); + + $body = $this->object->query("select mark from \"tcp.test\"", "ms"); $this->assertCount(1, $body[0]["points"]); $this->assertEquals("tcp.test", $body[0]["name"]); @@ -131,6 +143,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setUsername($rawOptions["udp"]["username"]); $options->setPassword($rawOptions["udp"]["password"]); $options->setPort($rawOptions["udp"]["port"]); + $options->setDatabase($rawOptions["udp"]["database"]); $adapter = new UdpAdapter($options); $object = new Client(); @@ -142,28 +155,32 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object->mark("udp.test", ["mark" => "element3"]); // Wait UDP/IP message arrives - usleep(200e3); + sleep(1); $this->options->setDatabase("udp.test"); - $body = $this->object->query("select * from udp.test"); + $body = $this->object->query("select * from \"udp.test\""); - $this->assertCount(4, $body[0]["points"]); - $this->assertEquals("udp.test", $body[0]["name"]); + $this->assertCount(4, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } public function testListActiveDatabses() { $databases = $this->object->getDatabases(); - $this->assertCount(2, $databases); + $this->assertCount(2, $databases["results"][0]["series"][0]["values"]); } public function testCreateANewDatabase() { $this->object->createDatabase("walter"); + + sleep(1); + $databases = $this->object->getDatabases(); - $this->assertCount(3, $databases); + $this->assertCount(3, $databases["results"][0]["series"][0]["values"]); $this->object->deleteDatabase("walter"); } diff --git a/tests/InfluxDB/HttpAdapterTest.php b/tests/InfluxDB/HttpAdapterTest.php deleted file mode 100644 index b7e1a4c4a..000000000 --- a/tests/InfluxDB/HttpAdapterTest.php +++ /dev/null @@ -1,131 +0,0 @@ -markTestSkipped(); - - $options = include __DIR__ . '/../bootstrap.php'; - $this->rawOptions = $options; - - $tcpOptions = $options["tcp"]; - - $options = new Options(); - $options->setHost($tcpOptions["host"]); - $options->setPort($tcpOptions["port"]); - $options->setUsername($tcpOptions["username"]); - $options->setPassword($tcpOptions["password"]); - $options->setDatabase($tcpOptions["database"]); - - $this->options = $options; - - $adapter = new HttpAdapter($options); - - $influx = new Client(); - $influx->setAdapter($adapter); - $this->object = $influx; - - $databases = $this->object->getDatabases(); - foreach ($databases as $database) { - $this->object->deleteDatabase($database["name"]); - } - - $this->object->createDatabase($this->rawOptions["tcp"]["database"]); - } - - /** - * @group tcp - */ - public function testApiWorksCorrectly() - { - $this->object->mark("tcp.test", ["mark" => "element"]); - - $body = $this->object->query("select * from tcp.test"); - $this->assertCount(1, $body[0]["points"]); - $this->assertEquals("element", $body[0]["points"][0][2]); - } - - /** - * @group tcp - */ - public function testQueryApiWorksCorrectly() - { - $this->object->mark("tcp.test", ["mark" => "element"]); - - $body = $this->object->query("select * from tcp.test"); - - $this->assertCount(1, $body); - $this->assertEquals("tcp.test", $body[0]["name"]); - $this->assertEquals("element", $body[0]["points"][0][2]); - } - - /** - * @group tcp - */ - public function testQueryApiWithMultipleData() - { - $this->object->mark("tcp.test", ["mark" => "element"]); - $this->object->mark("tcp.test", ["mark" => "element2"]); - $this->object->mark("tcp.test", ["mark" => "element3"]); - - $body = $this->object->query("select mark from tcp.test", "s"); - - $this->assertCount(3, $body[0]["points"]); - $this->assertEquals("tcp.test", $body[0]["name"]); - } - - /** - * @group tcp - */ - public function testQueryApiWithTimePrecision() - { - $this->object->mark("tcp.test", ["mark" => "element"]); - - $body = $this->object->query("select mark from tcp.test", "s"); - - $this->assertCount(1, $body[0]["points"]); - $this->assertEquals("tcp.test", $body[0]["name"]); - } - - /** - * @group tcp - */ - public function testWriteApiWithTimePrecision() - { - $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); - - $body = $this->object->query("select mark from tcp.test", "ms"); - - $this->assertCount(1, $body[0]["points"]); - $this->assertEquals("tcp.test", $body[0]["name"]); - - $this->assertEquals("1410591552000", $body[0]["points"][0][0]); - } - - public function testListActiveDatabses() - { - $databases = $this->object->getDatabases(); - - $this->assertCount(1, $databases); - } - - public function testCreateANewDatabase() - { - $this->object->createDatabase("walter"); - $databases = $this->object->getDatabases(); - - $this->assertCount(2, $databases); - - $this->object->deleteDatabase("walter"); - } -} From 4f3fdcb5437aca597899a0bc1557e4d981898cda Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 12:37:48 +0200 Subject: [PATCH 072/158] Dropped time precision feature --- src/InfluxDB/Adapter/AdapterInterface.php | 2 +- src/InfluxDB/Adapter/GuzzleAdapter.php | 41 --------------------- src/InfluxDB/Adapter/QueryableInterface.php | 29 +-------------- src/InfluxDB/Adapter/UdpAdapter.php | 2 +- src/InfluxDB/Client.php | 18 ++++----- tests/InfluxDB/ClientTest.php | 35 ------------------ 6 files changed, 10 insertions(+), 117 deletions(-) diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php index 73d1b2fe5..b4ac32821 100644 --- a/src/InfluxDB/Adapter/AdapterInterface.php +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -11,5 +11,5 @@ interface AdapterInterface * @param mixed $message * @param string|boolean $timePrecision */ - public function send($message, $timePrecision = false); + public function send($message); } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 2ebbceed1..fdd0d1680 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -78,47 +78,6 @@ class GuzzleAdapter implements AdapterInterface, QueryableInterface return $this->get($options); } - /** - * {@inheritDoc} - */ - public function getDatabases() - { - $options = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "query" => [ - "q" => "show databases", - ], - ]; - - return $this->get($options); - } - - /** - * {@inheritDoc} - */ - public function createDatabase($name) - { - $httpMessage = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "query" => ["q" => "CREATE DATABASE \"{$name}\""], - ]; - - return $this->get($httpMessage); - } - - /** - * {@inheritDoc} - */ - public function deleteDatabase($name) - { - $httpMessage = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], - "query" => ["q" => "drop database \"{$name}\""], - ]; - - return $this->get($httpMessage); - } - private function get(array $httpMessage) { $endpoint = $this->options->getHttpQueryEndpoint(); diff --git a/src/InfluxDB/Adapter/QueryableInterface.php b/src/InfluxDB/Adapter/QueryableInterface.php index 3bed92384..9ce4440dc 100644 --- a/src/InfluxDB/Adapter/QueryableInterface.php +++ b/src/InfluxDB/Adapter/QueryableInterface.php @@ -1,34 +1,7 @@ adapter; } - public function mark($name, array $values = [], $timePrecision = false) + public function mark($name, array $values = []) { $data = $name; if (!is_array($name)) { $data =[]; - $timePrecision = $this->clearTimePrecision($timePrecision); - $data["database"] = $this->getAdapter()->getOptions()->getDatabase(); $data['points'][0]['name'] = $name; $data['points'][0]['fields'] = $values; } - return $this->getAdapter()->send($data, $timePrecision); + return $this->getAdapter()->send($data); } - public function query($query, $timePrecision = false) + public function query($query) { if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - $timePrecision = $this->clearTimePrecision($timePrecision); - - $return = $this->getAdapter()->query($query, $timePrecision); + $return = $this->getAdapter()->query($query); return $return; } @@ -57,7 +53,7 @@ class Client if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - return $this->getAdapter()->getDatabases(); + return $this->getAdapter()->query("show databases"); } public function createDatabase($name) @@ -65,7 +61,7 @@ class Client if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - return $this->getAdapter()->createDatabase($name); + return $this->getAdapter()->query("create database \"{$name}\""); } public function deleteDatabase($name) @@ -73,7 +69,7 @@ class Client if (!($this->getAdapter() instanceOf QueryableInterface)) { throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); } - return $this->getAdapter()->deleteDatabase($name); + return $this->getAdapter()->query("drop database \"{$name}\""); } private function clearTimePrecision($timePrecision) diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index c569c420a..5a498452a 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -97,41 +97,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } - /** - * @group tcp - */ - public function testGuzzleHttpQueryApiWithTimePrecision() - { - $this->markTestSkipped("Skip time precision"); - $this->object->mark("tcp.test", ["mark" => "element"]); - - sleep(1); - - $body = $this->object->query("select mark from \"tcp.test\"", "s"); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group tcp - */ - public function testGuzzleHttpWriteApiWithTimePrecision() - { - $this->markTestSkipped("Skip time precision"); - $this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s"); - - sleep(1); - - $body = $this->object->query("select mark from \"tcp.test\"", "ms"); - - $this->assertCount(1, $body[0]["points"]); - $this->assertEquals("tcp.test", $body[0]["name"]); - - $this->assertEquals("1410591552000", $body[0]["points"][0][0]); - } - /** * @group udp */ From 72b08569e92a8a20413baec2ca6e1cba53c1e300 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 13:03:06 +0200 Subject: [PATCH 073/158] Added test for direct messsages with HTTP client --- README.md | 38 ++++++++++++++++++++++------------- tests/InfluxDB/ClientTest.php | 30 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5d766d332..fc78d5743 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Send metrics to InfluxDB and query for any data. +**For InfluxDB v0.8 checkout branch 0.3** + ## Install it Just use composer @@ -34,6 +36,27 @@ $client->mark("app.search", [ ]); ``` +Or use InfluxDB direct messages + +```php +$client->mark([ + "database" => "mydb", + "tags" => [ + "dc" => "eu-west-1", + ], + "points" => [ + [ + "name" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] +]); +``` + + Retrieve existing points: ```php @@ -61,7 +84,7 @@ php -m | grep sockets If you don't have the `sockets` extension, you can proceed in two ways: - Recompile your PHP whith the `--enable-sockets` flag -- Or just compile the `sockets` extension extracting it from the PHP source. +- Or just compile the `sockets` extension extracting it from the PHP source. 1. Download the source relative to the PHP version that you on from [here](https://github.com/php/php-src/releases) 2. Enter in the `ext/sockets` directory 3. Issue a `phpize && ./configure && make -j && sudo make install` @@ -124,25 +147,12 @@ $client->mark("error.404", ["page" => "/a-missing-page"]); Of course you can always use the DiC or your service manager in order to create a valid client instance. -### Time Precision write/read queries - -You can set the `time_precision` for query query - -```php -$client->mark("app.search", $points, "s"); //points contains "time" that is in seconds -``` - -```php -$client->query("select * from app.search", "s"); // retrieve points using seconds for time column -``` - ### Query InfluxDB You can query the time series database using the query method. ```php $influx->query("select * from mine"); -$influx->query("select * from mine", "s"); // with time_precision ``` You can query the database only if the adapter is queryable (implements diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 5a498452a..744a6e1ef 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -97,6 +97,36 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } + /** + * @group tcp + */ + public function testWriteDirectMessages() + { + $this->object->mark([ + "database" => "tcp.test", + "tags" => [ + "dc" => "eu-west-1", + ], + "points" => [ + [ + "name" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + sleep(1); + + $body = $this->object->query("select * from \"vm-serie\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); + } + /** * @group udp */ From 63207b4551a16ab4eb3e048c56c4b61b1b7a6aa4 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 13:08:33 +0200 Subject: [PATCH 074/158] Added test UDP/IP supports direct messages --- tests/InfluxDB/ClientTest.php | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 744a6e1ef..a57265185 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -160,6 +160,50 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } + /** + * @group udp + */ + public function testWriteDirectMessageWithUdpIp() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setHost($rawOptions["udp"]["host"]); + $options->setUsername($rawOptions["udp"]["username"]); + $options->setPassword($rawOptions["udp"]["password"]); + $options->setPort($rawOptions["udp"]["port"]); + $options->setDatabase($rawOptions["udp"]["database"]); + + $adapter = new UdpAdapter($options); + $object = new Client(); + $object->setAdapter($adapter); + + $this->object->mark([ + "database" => "udp.test", + "tags" => [ + "dc" => "eu-west-1", + ], + "points" => [ + [ + "name" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + sleep(1); + + $this->options->setDatabase("udp.test"); + $body = $this->object->query("select * from \"vm-serie\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); + $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); + } + public function testListActiveDatabses() { $databases = $this->object->getDatabases(); From 311411d9420fe4b707369970ca81da4f7974b70c Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 13:18:13 +0200 Subject: [PATCH 075/158] Updated docs --- README.md | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index fc78d5743..2225da463 100644 --- a/README.md +++ b/README.md @@ -106,22 +106,15 @@ Actually Guzzle is used as HTTP client library ```php setAdapter($adapter); ``` -#### Supported types of exceptions - -* InfluxGeneralException -* InfluxAuthorizationException (extends InfluxGeneralException) -* InfluxBadResponseException (extends InfluxGeneralException) -* InfluxNoSeriesException (extends InfluxGeneralException) -* InfluxUnexpectedResponseException (extends InfluxGeneralException) - ### Create your client with the factory method Effectively the client creation is not so simple, for that @@ -130,13 +123,14 @@ reason you can you the factory method provided with the library. ```php $options = [ "adapter" => [ - "name" => "InfluxDB\\Adapter\\HttpAdapter", + "name" => "InfluxDB\\Adapter\\GuzzleAdapter", "options" => [ // guzzle options ], ], "options" => [ "host" => "my.influx.domain.tld", + "db" => "mydb", ] ]; $client = \InfluxDB\ClientFactory::create($options); @@ -152,7 +146,7 @@ a valid client instance. You can query the time series database using the query method. ```php -$influx->query("select * from mine"); +$influx->query('select * from "mine"'); ``` You can query the database only if the adapter is queryable (implements @@ -163,29 +157,13 @@ like: ``` array(1) { - [0] => - class stdClass#1 (3) { - public $name => - string(8) "tcp.test" - public $columns => - array(3) { - [0] => - string(4) "time" - [1] => - string(15) "sequence_number" - [2] => - string(4) "mark" - } - public $points => + 'results' => + array(1) { + [0] => array(1) { - [0] => - array(3) { - [0] => - int(1410545635590) - [1] => - int(2390001) - [2] => - string(7) "element" + 'series' => + array(1) { + ... } } } From b65eb99d9ff9e5d1068d3864b105e578477928c0 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 13:24:47 +0200 Subject: [PATCH 076/158] Removed filter benchmarks --- .../Benchmarks/InfluxDB/FilterEvent.php | 111 ------------------ 1 file changed, 111 deletions(-) delete mode 100644 benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php diff --git a/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php b/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php deleted file mode 100644 index e12ebaf4d..000000000 --- a/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php +++ /dev/null @@ -1,111 +0,0 @@ -testData = [ - (object)[ - "name" => "test", - "columns" => [ - "time", - "sequence_number", - "value", - ], - "points" => [ - ], - ] - ]; - - $prophet = new Prophet; - $adapter = $prophet->prophesize('InfluxDB\Adapter\GuzzleAdapter'); - $adapter->query(Argument::any(), Argument::Any())->willReturn($this->testData); - - $this->withFilter = new Client(); - $this->withFilter->setAdapter($adapter->reveal()); - $this->withFilter->setFilter(new ColumnsPointsFilter()); - - $this->withoutFilter = new Client(); - $this->withoutFilter->setAdapter($adapter->reveal()); - } - - /** - * @iterations 10000 - */ - public function get10PointDirectData() - { - for ($i=0; $i<10; $i++) { - $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; - } - - $this->withoutFilter->query("THE QUERY", "s"); - } - - /** - * @iterations 10000 - */ - public function get10PointFilteredData() - { - for ($i=0; $i<10; $i++) { - $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; - } - $this->withFilter->query("THE QUERY", "s"); - } - - /** - * @iterations 1000 - */ - public function get100PointDirectData() - { - for ($i=0; $i<100; $i++) { - $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; - } - - $this->withoutFilter->query("THE QUERY", "s"); - } - - /** - * @iterations 1000 - */ - public function get100PointFilteredData() - { - for ($i=0; $i<100; $i++) { - $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; - } - $this->withFilter->query("THE QUERY", "s"); - } - - /** - * @iterations 100 - */ - public function get1000PointDirectData() - { - for ($i=0; $i<1000; $i++) { - $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; - } - - $this->withoutFilter->query("THE QUERY", "s"); - } - - /** - * @iterations 100 - */ - public function get1000PointFilteredData() - { - for ($i=0; $i<1000; $i++) { - $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; - } - $this->withFilter->query("THE QUERY", "s"); - } -} From 70c0f57bfa308863ea0299232f50056324e165ff Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 13:32:32 +0200 Subject: [PATCH 077/158] Updated benchmarks and bench results --- README.md | 5 +++-- benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2225da463..f453099d9 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,7 @@ The impact using UDP or HTTP adapters Corley\Benchmarks\InfluxDB\AdapterEvent Method Name Iterations Average Time Ops/second ------------------------ ------------ -------------- ------------- - sendDataUsingHttpAdapter: [1,000 ] [0.0026700308323] [374.52751] - sendDataUsingUdpAdapter : [1,000 ] [0.0000436344147] [22,917.69026] + sendDataUsingHttpAdapter: [1,000 ] [0.0098177127838] [101.85672] + sendDataUsingUdpAdapter : [1,000 ] [0.0000694372654] [14,401.48880] ``` + diff --git a/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php b/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php index 55b418358..ba43adac0 100644 --- a/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php +++ b/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php @@ -17,16 +17,22 @@ class AdapterEvent extends AthleticEvent { $client = new Client(); $options = new Options(); + $options->setHost("localhost"); + $options->setPort(8086); $options->setUsername("root"); $options->setPassword("root"); - $options->setDatabase("bench"); + $options->setDatabase("tcp.test"); $client->setAdapter( new GuzzleAdapter(new HttpClient(), $options) ); $this->httpClient = $client; + $opts = new Options(); + $opts->setPort(4444); + $client = new Client(); - $client->setAdapter(new UdpAdapter(new Options())); + $client->setAdapter(new UdpAdapter($opts)); + $this->udpClient = $client; } From 9ed7fe6ba4a323b22dc519e2fbd7cb2dda188c38 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 13:35:47 +0200 Subject: [PATCH 078/158] Prepare new travis-ci runner --- .travis.yml | 29 +++-- scripts/influxdb_conf.toml | 241 +++++++++++++------------------------ 2 files changed, 100 insertions(+), 170 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e669d0d3..63b3ea312 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,22 @@ language: php php: -- 5.4 -- 5.5 -- 5.6 + - 5.4 + - 5.5 + - 5.6 before_install: -- sudo apt-get update -- sudo apt-get install libcurl4-openssl-dev libjson0-dev -- wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb -- sudo useradd influxdb -- sudo dpkg -i influxdb_latest_amd64.deb -- sudo cp ./scripts/influxdb_conf.toml /opt/influxdb/shared/config.toml -- travis_retry sudo service influxdb restart -- sudo service influxdb status + - sudo apt-get update + - sudo apt-get install libcurl4-openssl-dev libjson0-dev + - wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb + - sudo useradd influxdb + - sudo dpkg -i influxdb_latest_amd64.deb + - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf + - travis_retry sudo service influxdb restart + - sudo service influxdb status before_script: -- composer selfupdate -- composer install --prefer-source + - composer selfupdate + - composer install --prefer-source script: -- vendor/bin/phpspec run -n -- vendor/bin/phpunit + - vendor/bin/phpunit notifications: slack: secure: UN4V33CfLzEcb+5/LWcfcbwROZobbUawgFSiM3TzagBC+7w0DH2rK8DczxkUBs5rNAaYBj+DkxmmF9tiDb0BLB7Jezlq0vmrNBOhregLodOG44/bFwg58YOwTGxt/Iak38A+8VskGj0sSybNq4TB1/K0040wXS5bA+M/9NqyQeo= diff --git a/scripts/influxdb_conf.toml b/scripts/influxdb_conf.toml index 4c946e0b3..235f2ec84 100644 --- a/scripts/influxdb_conf.toml +++ b/scripts/influxdb_conf.toml @@ -4,184 +4,115 @@ # systems in the cluster, you'll have to set the hostname to an IP or something # that can be resolved here. # hostname = "" - bind-address = "0.0.0.0" +# The default cluster and API port +port = 8086 + # Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com -# The data includes raft name (random 8 bytes), os, arch and version +# The data includes raft id (random 8 bytes), os, arch and version # We don't track ip addresses of servers reporting. This is only used -# to track the number of instances running and the versions which +# to track the number of instances running and the versions, which # is very helpful for us. # Change this option to true to disable reporting. reporting-disabled = false -[logging] -# logging level can be one of "debug", "info", "warn" or "error" -level = "info" -file = "/opt/influxdb/shared/log.txt" # stdout to log to standard out +# Controls settings for initial start-up. Once a node is successfully started, +# these settings are ignored. If a node is started with the -join flag, +# these settings are ignored. +[initialization] +join-urls = "" # Comma-delimited URLs, in the form http://host:port, for joining another cluster. + +# Control authentication +# If not set authetication is DISABLED. Be sure to explicitly set this flag to +# true if you want authentication. +[authentication] +enabled = false # Configure the admin server [admin] -port = 8083 # binding is disabled if the port isn't set -assets = "/opt/influxdb/current/admin" +enabled = true +port = 8083 -# Configure the http api +# Configure the HTTP API endpoint. All time-series data and queries uses this endpoint. [api] -port = 8086 # binding is disabled if the port isn't set -# ssl-port = 8084 # Ssl support is enabled if you set a port and cert -# ssl-cert = /path/to/cert.pem +# ssl-port = 8087 # SSL support is enabled if you set a port and cert +# ssl-cert = "/path/to/cert.pem" -# connections will timeout after this amount of time. Ensures that clients that misbehave -# and keep alive connections they don't use won't end up connection a million times. -# However, if a request is taking longer than this to complete, could be a problem. -read-timeout = "5s" +# Configure the Graphite plugins. +[[graphite]] # 1 or more of these sections may be present. +enabled = false +# protocol = "" # Set to "tcp" or "udp" +# address = "0.0.0.0" # If not set, is actually set to bind-address. +# port = 2003 +# name-position = "last" +# name-separator = "-" +# database = "" # store graphite data in this database -[input_plugins] +# Configure the collectd input. +[collectd] +enabled = false +#address = "0.0.0.0" # If not set, is actually set to bind-address. +#port = 25827 +#database = "collectd_database" +#typesdb = "types.db" - # Configure the graphite api - [input_plugins.graphite] - enabled = false - # port = 2003 - # database = "" # store graphite data in this database - # udp_enabled = true # enable udp interface on the same port as the tcp interface +# Configure the OpenTSDB input. +[opentsdb] +enabled = false +#address = "0.0.0.0" # If not set, is actually set to bind-address. +#port = 4242 +#database = "opentsdb_database" - # Configure the udp api - #[input_plugins.udp] - #enabled = true - #port = 4444 - # database = "" +# Configure UDP listener for series data. +[udp] +enabled = true +bind-address = "0.0.0.0" +port = 4444 - # Configure multiple udp apis each can write to separate db. Just - # repeat the following section to enable multiple udp apis on - # different ports. - [[input_plugins.udp_servers]] # array of tables - enabled = true - port = 5551 - database = "udp.test" +# Broker configuration. Brokers are nodes which participate in distributed +# consensus. +[broker] +enabled = true +# Where the Raft logs are stored. The user running InfluxDB will need read/write access. +dir = "/var/opt/influxdb/raft" +truncation-interval = "10m" +max-topic-size = 52428800 +max-segment-size = 10485760 -# Raft configuration +# Raft configuration. Controls the distributed consensus system. [raft] -# The raft port should be open between all servers in a cluster. -# However, this port shouldn't be accessible from the internet. +apply-interval = "10ms" +election-timeout = "5s" +heartbeat-interval = "100ms" +reconnect-timeout = "10ms" -port = 8090 +# Data node configuration. Data nodes are where the time-series data, in the form of +# shards, is stored. +[data] +enabled = true +dir = "/var/opt/influxdb/db" -# Where the raft logs are stored. The user running InfluxDB will need read/write access. -dir = "/opt/influxdb/shared/data/raft" +# Auto-create a retention policy when a database is created. Defaults to true. +retention-auto-create = true -# election-timeout = "1s" +# Control whether retention policies are enforced and how long the system waits between +# enforcing those policies. +retention-check-enabled = true +retention-check-period = "10m" -[storage] +# Configuration for snapshot endpoint. +[snapshot] +enabled = true # Enabled by default if not set. -dir = "/opt/influxdb/shared/data/db" -# How many requests to potentially buffer in memory. If the buffer gets filled then writes -# will still be logged and once the local storage has caught up (or compacted) the writes -# will be replayed from the WAL -write-buffer-size = 10000 +[logging] +write-tracing = false # If true, enables detailed logging of the write system. +raft-tracing = false # If true, enables detailed logging of Raft consensus. +http-access = true # If true, logs each HTTP access to the system. -# the engine to use for new shards, old shards will continue to use the same engine -default-engine = "rocksdb" - -# The default setting on this is 0, which means unlimited. Set this to something if you want to -# limit the max number of open files. max-open-files is per shard so this * that will be max. -max-open-shards = 0 - -# The default setting is 100. This option tells how many points will be fetched from LevelDb before -# they get flushed into backend. -point-batch-size = 100 - -# The number of points to batch in memory before writing them to leveldb. Lowering this number will -# reduce the memory usage, but will result in slower writes. -write-batch-size = 5000000 - -# The server will check this often for shards that have expired that should be cleared. -retention-sweep-period = "10m" - -[storage.engines.leveldb] - -# Maximum mmap open files, this will affect the virtual memory used by -# the process -max-open-files = 1000 - -# LRU cache size, LRU is used by leveldb to store contents of the -# uncompressed sstables. You can use `m` or `g` prefix for megabytes -# and gigabytes, respectively. -lru-cache-size = "200m" - -[storage.engines.rocksdb] - -# Maximum mmap open files, this will affect the virtual memory used by -# the process -max-open-files = 1000 - -# LRU cache size, LRU is used by rocksdb to store contents of the -# uncompressed sstables. You can use `m` or `g` prefix for megabytes -# and gigabytes, respectively. -lru-cache-size = "200m" - -[storage.engines.hyperleveldb] - -# Maximum mmap open files, this will affect the virtual memory used by -# the process -max-open-files = 1000 - -# LRU cache size, LRU is used by rocksdb to store contents of the -# uncompressed sstables. You can use `m` or `g` prefix for megabytes -# and gigabytes, respectively. -lru-cache-size = "200m" - -[storage.engines.lmdb] - -map-size = "100g" - -[cluster] -# A comma separated list of servers to seed -# this server. this is only relevant when the -# server is joining a new cluster. Otherwise -# the server will use the list of known servers -# prior to shutting down. Any server can be pointed to -# as a seed. It will find the Raft leader automatically. - -# Here's an example. Note that the port on the host is the same as the raft port. -# seed-servers = ["hosta:8090","hostb:8090"] - -# Replication happens over a TCP connection with a Protobuf protocol. -# This port should be reachable between all servers in a cluster. -# However, this port shouldn't be accessible from the internet. - -protobuf_port = 8099 -protobuf_timeout = "2s" # the write timeout on the protobuf conn any duration parseable by time.ParseDuration -protobuf_heartbeat = "200ms" # the heartbeat interval between the servers. must be parseable by time.ParseDuration -protobuf_min_backoff = "1s" # the minimum backoff after a failed heartbeat attempt -protobuf_max_backoff = "10s" # the maxmimum backoff after a failed heartbeat attempt - -# How many write requests to potentially buffer in memory per server. If the buffer gets filled then writes -# will still be logged and once the server has caught up (or come back online) the writes -# will be replayed from the WAL -write-buffer-size = 1000 - -# the maximum number of responses to buffer from remote nodes, if the -# expected number of responses exceed this number then querying will -# happen sequentially and the buffer size will be limited to this -# number -max-response-buffer-size = 100 - -# When queries get distributed out to shards, they go in parallel. This means that results can get buffered -# in memory since results will come in any order, but have to be processed in the correct time order. -# Setting this higher will give better performance, but you'll need more memory. Setting this to 1 will ensure -# that you don't need to buffer in memory, but you won't get the best performance. -concurrent-shard-query-limit = 10 - -[wal] - -dir = "/opt/influxdb/shared/data/wal" -flush-after = 1000 # the number of writes after which wal will be flushed, 0 for flushing on every write -bookmark-after = 1000 # the number of writes after which a bookmark will be created - -# the number of writes after which an index entry is created pointing -# to the offset of the first request, default to 1k -index-after = 1000 - -# the number of requests per one log file, if new requests came in a -# new log file will be created -requests-per-logfile = 10000 +# InfluxDB can store statistical and diagnostic information about itself. This is useful for +# monitoring purposes. This feature is disabled by default, but if enabled, these data can be +# queried like any other data. +[monitoring] +enabled = false +write-interval = "1m" # Period between writing the data. From a5e5da5f23b9b880f220afdad9880dedf2260d6f Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Tue, 19 May 2015 12:19:19 +0200 Subject: [PATCH 079/158] Update travis configuration to install InfluxDB 0.9rc30 Conflicts: .travis.yml --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 63b3ea312..16014f0c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,27 @@ language: php + php: - 5.4 - 5.5 - 5.6 + before_install: - sudo apt-get update - sudo apt-get install libcurl4-openssl-dev libjson0-dev - - wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb + - wget http://get.influxdb.org/influxdb_0.9.0-rc30_amd64.deb - sudo useradd influxdb - sudo dpkg -i influxdb_latest_amd64.deb - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - travis_retry sudo service influxdb restart - sudo service influxdb status + before_script: - composer selfupdate - composer install --prefer-source + script: - vendor/bin/phpunit + notifications: slack: secure: UN4V33CfLzEcb+5/LWcfcbwROZobbUawgFSiM3TzagBC+7w0DH2rK8DczxkUBs5rNAaYBj+DkxmmF9tiDb0BLB7Jezlq0vmrNBOhregLodOG44/bFwg58YOwTGxt/Iak38A+8VskGj0sSybNq4TB1/K0040wXS5bA+M/9NqyQeo= From d43f449dee931ba499f11a2240de37b91f35366d Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 22:53:39 +0200 Subject: [PATCH 080/158] Fixes install file name --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 16014f0c8..2b9bf344f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_install: - sudo apt-get install libcurl4-openssl-dev libjson0-dev - wget http://get.influxdb.org/influxdb_0.9.0-rc30_amd64.deb - sudo useradd influxdb - - sudo dpkg -i influxdb_latest_amd64.deb + - sudo dpkg -i influxdb_0.9.0-rc30_amd64.deb - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - travis_retry sudo service influxdb restart - sudo service influxdb status From 35b8dd014915796f36221df610aa7d3b9d002c36 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 7 Jun 2015 23:15:40 +0200 Subject: [PATCH 081/158] Added tags test case --- tests/InfluxDB/ClientTest.php | 64 ++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index a57265185..f86d04055 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -177,11 +177,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object = new Client(); $object->setAdapter($adapter); - $this->object->mark([ + $object->mark([ "database" => "udp.test", - "tags" => [ - "dc" => "eu-west-1", - ], "points" => [ [ "name" => "vm-serie", @@ -204,6 +201,65 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); } + /** + * @group udp + * @group tags + */ + public function testTagsAreWrittenCorrectly() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setHost($rawOptions["udp"]["host"]); + $options->setUsername($rawOptions["udp"]["username"]); + $options->setPassword($rawOptions["udp"]["password"]); + $options->setPort($rawOptions["udp"]["port"]); + $options->setDatabase($rawOptions["udp"]["database"]); + + $adapter = new UdpAdapter($options); + $object = new Client(); + $object->setAdapter($adapter); + + $object->mark([ + "database" => "udp.test", + "tags" => [ + "region" => "eu", + ], + "points" => [ + [ + "name" => "vm-serie", + "tags" => [ + "dc" => "eu-west-1", + "one" => "two", + ], + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + [ + "name" => "vm-serie", + "tags" => [ + "dc" => "us-east-1", + ], + "fields" => [ + "cpu" => 28.12, + "free" => 412923, + ], + ], + ] + ]); + + sleep(1); + + $this->options->setDatabase("udp.test"); + $body = $this->object->query("select * from \"vm-serie\" where dc='eu-west-1'"); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); + $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); + } + public function testListActiveDatabses() { $databases = $this->object->getDatabases(); From f8bb3fcde49bcfae50f34af5720ebf2e6430c850 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Mon, 8 Jun 2015 18:58:52 +0200 Subject: [PATCH 082/158] Use prepared default options In order to use user prepared options the message is alse merged with all user preapared options. --- src/InfluxDB/Adapter/AdapterAbstract.php | 34 +++++++++++++++ src/InfluxDB/Adapter/AdapterInterface.php | 2 +- src/InfluxDB/Adapter/GuzzleAdapter.php | 51 +++++------------------ src/InfluxDB/Adapter/UdpAdapter.php | 31 ++------------ src/InfluxDB/Client.php | 1 - tests/InfluxDB/ClientTest.php | 46 ++++++++++++++++++-- 6 files changed, 91 insertions(+), 74 deletions(-) create mode 100644 src/InfluxDB/Adapter/AdapterAbstract.php diff --git a/src/InfluxDB/Adapter/AdapterAbstract.php b/src/InfluxDB/Adapter/AdapterAbstract.php new file mode 100644 index 000000000..cc39dab6f --- /dev/null +++ b/src/InfluxDB/Adapter/AdapterAbstract.php @@ -0,0 +1,34 @@ +options = $options; + } + + /** + * @return Options + */ + public function getOptions() + { + return $this->options; + } + + protected function getMessageDefaults() + { + return [ + "database" => $this->getOptions()->getDatabase(), + ]; + } + + abstract public function send(array $message); +} diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/InfluxDB/Adapter/AdapterInterface.php index b4ac32821..23bdf7a68 100644 --- a/src/InfluxDB/Adapter/AdapterInterface.php +++ b/src/InfluxDB/Adapter/AdapterInterface.php @@ -11,5 +11,5 @@ interface AdapterInterface * @param mixed $message * @param string|boolean $timePrecision */ - public function send($message); + public function send(array $message); } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index fdd0d1680..9a4d1ab78 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -10,77 +10,46 @@ use InfluxDB\Options; * * @deprecated */ -class GuzzleAdapter implements AdapterInterface, QueryableInterface +class GuzzleAdapter extends AdapterAbstract implements QueryableInterface { - /** - * @var GuzzleHttp\Client - */ private $httpClient; - /** - * @var \InfluxDB\Options - */ - private $options; - - /** - * @param Client $httpClient - * @param Options $options - */ public function __construct(Client $httpClient, Options $options) { + parent::__construct($options); + $this->httpClient = $httpClient; - $this->options = $options; } - /** - * @return Options - */ - public function getOptions() + public function send(array $message) { - return $this->options; - } + $message = array_replace_recursive($this->getMessageDefaults(), $message); - /** - * {@inheritDoc} - */ - public function send($message, $timePrecision = false) - { $httpMessage = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], + "auth" => [$this->getOptions()->getUsername(), $this->getOptions()->getPassword()], "body" => json_encode($message) ]; - if ($timePrecision) { - $httpMessage["query"]["time_precision"] = $timePrecision; - } - - $endpoint = $this->options->getHttpSeriesEndpoint(); + $endpoint = $this->getOptions()->getHttpSeriesEndpoint(); return $this->httpClient->post($endpoint, $httpMessage); } - /** - * {@inheritDoc} - */ - public function query($query, $timePrecision = false) + public function query($query) { $options = [ - "auth" => [$this->options->getUsername(), $this->options->getPassword()], + "auth" => [$this->getOptions()->getUsername(), $this->getOptions()->getPassword()], 'query' => [ "q" => $query, "db" => $this->getOptions()->getDatabase(), ] ]; - if ($timePrecision) { - $options["query"]["time_precision"] = $timePrecision; - } - return $this->get($options); } private function get(array $httpMessage) { - $endpoint = $this->options->getHttpQueryEndpoint(); + $endpoint = $this->getOptions()->getHttpQueryEndpoint(); return $this->httpClient->get($endpoint, $httpMessage)->json(); } } diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index 090098dab..39a9a7570 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -3,38 +3,15 @@ namespace InfluxDB\Adapter; use InfluxDB\Options; -/** - * Clent adapter to call InfluxDb by UDP protocol - * @link http://influxdb.com/docs/v0.6/api/reading_and_writing_data.html#writing-data-through-json-+-udp - */ -class UdpAdapter implements AdapterInterface +final class UdpAdapter extends AdapterAbstract { - private $options; - - /** - * @param Options $options - */ - public function __construct(Options $options) + public function send(array $message) { - $this->options = $options; - } + $message = array_replace_recursive($this->getMessageDefaults(), $message); - /** - * @return Options - */ - public function getOptions() - { - return $this->options; - } - - /** - * {@inheritDoc} - */ - public function send($message) - { $message = json_encode($message); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - socket_sendto($socket, $message, strlen($message), 0, $this->options->getHost(), $this->options->getPort()); + socket_sendto($socket, $message, strlen($message), 0, $this->getOptions()->getHost(), $this->getOptions()->getPort()); socket_close($socket); } } diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index cc270d60e..bfaf09fa0 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -29,7 +29,6 @@ class Client if (!is_array($name)) { $data =[]; - $data["database"] = $this->getAdapter()->getOptions()->getDatabase(); $data['points'][0]['name'] = $name; $data['points'][0]['fields'] = $values; } diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index f86d04055..27a42773d 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -53,7 +53,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testGuzzleHttpApiWorksCorrectly() { - $t = $this->object->mark("tcp.test", ["mark" => "element"]); + $this->object->mark("tcp.test", ["mark" => "element"]); sleep(1); @@ -103,7 +103,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase public function testWriteDirectMessages() { $this->object->mark([ - "database" => "tcp.test", "tags" => [ "dc" => "eu-west-1", ], @@ -160,6 +159,47 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } + /** + * @group udp + */ + public function testOverrideDatabaseNameViaMessage() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setHost($rawOptions["udp"]["host"]); + $options->setUsername($rawOptions["udp"]["username"]); + $options->setPassword($rawOptions["udp"]["password"]); + $options->setPort($rawOptions["udp"]["port"]); + $options->setDatabase("a-wrong-database"); + + $adapter = new UdpAdapter($options); + $object = new Client(); + $object->setAdapter($adapter); + + $object->mark([ + "database" => "{$rawOptions["udp"]["database"]}", + "points" => [ + [ + "name" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + sleep(1); + + $this->options->setDatabase($rawOptions["udp"]["database"]); + $body = $this->object->query("select * from \"vm-serie\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); + $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); + } + /** * @group udp */ @@ -178,7 +218,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object->setAdapter($adapter); $object->mark([ - "database" => "udp.test", "points" => [ [ "name" => "vm-serie", @@ -220,7 +259,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object->setAdapter($adapter); $object->mark([ - "database" => "udp.test", "tags" => [ "region" => "eu", ], From 4fa039337b27f29d31f5d2a8d2a7acd5188a3a08 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Mon, 8 Jun 2015 19:05:14 +0200 Subject: [PATCH 083/158] Added retention policy as option --- src/InfluxDB/Adapter/AdapterAbstract.php | 1 + src/InfluxDB/Options.php | 67 +++++++----------------- 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/src/InfluxDB/Adapter/AdapterAbstract.php b/src/InfluxDB/Adapter/AdapterAbstract.php index cc39dab6f..f933c866b 100644 --- a/src/InfluxDB/Adapter/AdapterAbstract.php +++ b/src/InfluxDB/Adapter/AdapterAbstract.php @@ -27,6 +27,7 @@ abstract class AdapterAbstract implements AdapterInterface { return [ "database" => $this->getOptions()->getDatabase(), + "retentionPolicy" => $this->getOptions()->getRetentionPolicy(), ]; } diff --git a/src/InfluxDB/Options.php b/src/InfluxDB/Options.php index 16f157fd0..3b4693b25 100644 --- a/src/InfluxDB/Options.php +++ b/src/InfluxDB/Options.php @@ -37,16 +37,31 @@ class Options */ private $database; + private $retentionPolicy; + /** * Set default options */ public function __construct() { - $this->host = "localhost"; - $this->port = 8086; - $this->username = "root"; - $this->password = "root"; + $this->setHost("localhost"); + $this->setPort(8086); + $this->setUsername("root"); + $this->setPassword("root"); $this->setProtocol("http"); + + $this->setRetentionPolicy("default"); + } + + public function getRetentionPolicy() + { + return $this->retentionPolicy; + } + + public function setRetentionPolicy($retentionPolicy) + { + $this->retentionPolicy = $retentionPolicy; + return $this; } /** @@ -57,19 +72,12 @@ class Options return $this->protocol; } - /** - * @param string $protocol - * @return Options - */ public function setProtocol($protocol) { $this->protocol = $protocol; return $this; } - /** - * @return string - */ public function getHost() { return $this->host; @@ -81,82 +89,50 @@ class Options return $this; } - /** - * @return string|int - */ public function getPort() { return $this->port; } - /** - * @param string|int $port - * @return Options - */ public function setPort($port) { $this->port = $port; return $this; } - /** - * @return string - */ public function getUsername() { return $this->username; } - /** - * @param string $usarname - * @return Options - */ public function setUsername($username) { $this->username = $username; return $this; } - /** - * @return string - */ public function getPassword() { return $this->password; } - /** - * @param string $password - * @return Options - */ public function setPassword($password) { $this->password = $password; return $this; } - /** - * @return string - */ public function getDatabase() { return $this->database; } - /** - * @param string $database - * @return Options - */ public function setDatabase($database) { $this->database = $database; return $this; } - /** - * Build http series edpoint - * @return string - */ public function getHttpSeriesEndpoint() { return sprintf( @@ -167,11 +143,6 @@ class Options ); } - /** - * Build http database endpoint by name - * @param string $name - * @return string - */ public function getHttpQueryEndpoint($name = false) { $url = sprintf( From 94fa4e67b268804455bb6781397a69cd4ff3c5e6 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 11:40:43 +0200 Subject: [PATCH 084/158] Complete refactor in order to support RC-32 The influxdb RC-32 is quite strange, uses a UDP/IP line protocol with batch updates. This commit will cover the base UDP/IP protocol as first implementation --- .travis.yml | 5 +- scripts/influxdb_conf.toml | 176 ++++++++-------------- src/InfluxDB/Adapter/AdapterAbstract.php | 1 + src/InfluxDB/Adapter/GuzzleAdapter.php | 4 + src/InfluxDB/Adapter/UdpAdapter.php | 59 +++++++- src/InfluxDB/Client.php | 2 +- src/InfluxDB/Options.php | 35 ++--- tests/InfluxDB/Adapter/UdpAdapterTest.php | 64 ++++++++ tests/InfluxDB/ClientTest.php | 91 +++++------ 9 files changed, 251 insertions(+), 186 deletions(-) create mode 100644 tests/InfluxDB/Adapter/UdpAdapterTest.php diff --git a/.travis.yml b/.travis.yml index 2b9bf344f..2b0b653e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,15 @@ language: php php: - - 5.4 - 5.5 - 5.6 before_install: - sudo apt-get update - sudo apt-get install libcurl4-openssl-dev libjson0-dev - - wget http://get.influxdb.org/influxdb_0.9.0-rc30_amd64.deb + - wget http://get.influxdb.org/influxdb_0.9.0-rc32_amd64.deb - sudo useradd influxdb - - sudo dpkg -i influxdb_0.9.0-rc30_amd64.deb + - sudo dpkg -i influxdb_0.9.0-rc32_amd64.deb - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - travis_retry sudo service influxdb restart - sudo service influxdb status diff --git a/scripts/influxdb_conf.toml b/scripts/influxdb_conf.toml index 235f2ec84..9c2568114 100644 --- a/scripts/influxdb_conf.toml +++ b/scripts/influxdb_conf.toml @@ -1,118 +1,74 @@ -# Welcome to the InfluxDB configuration file. +[meta] + dir = "/var/opt/influxdb/meta" + hostname = "localhost" + bind-address = ":8088" + retention-autocreate = true + election-timeout = "1s" + heartbeat-timeout = "1s" + leader-lease-timeout = "500ms" + commit-timeout = "50ms" -# If hostname (on the OS) doesn't return a name that can be resolved by the other -# systems in the cluster, you'll have to set the hostname to an IP or something -# that can be resolved here. -# hostname = "" -bind-address = "0.0.0.0" - -# The default cluster and API port -port = 8086 - -# Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com -# The data includes raft id (random 8 bytes), os, arch and version -# We don't track ip addresses of servers reporting. This is only used -# to track the number of instances running and the versions, which -# is very helpful for us. -# Change this option to true to disable reporting. -reporting-disabled = false - -# Controls settings for initial start-up. Once a node is successfully started, -# these settings are ignored. If a node is started with the -join flag, -# these settings are ignored. -[initialization] -join-urls = "" # Comma-delimited URLs, in the form http://host:port, for joining another cluster. - -# Control authentication -# If not set authetication is DISABLED. Be sure to explicitly set this flag to -# true if you want authentication. -[authentication] -enabled = false - -# Configure the admin server -[admin] -enabled = true -port = 8083 - -# Configure the HTTP API endpoint. All time-series data and queries uses this endpoint. -[api] -# ssl-port = 8087 # SSL support is enabled if you set a port and cert -# ssl-cert = "/path/to/cert.pem" - -# Configure the Graphite plugins. -[[graphite]] # 1 or more of these sections may be present. -enabled = false -# protocol = "" # Set to "tcp" or "udp" -# address = "0.0.0.0" # If not set, is actually set to bind-address. -# port = 2003 -# name-position = "last" -# name-separator = "-" -# database = "" # store graphite data in this database - -# Configure the collectd input. -[collectd] -enabled = false -#address = "0.0.0.0" # If not set, is actually set to bind-address. -#port = 25827 -#database = "collectd_database" -#typesdb = "types.db" - -# Configure the OpenTSDB input. -[opentsdb] -enabled = false -#address = "0.0.0.0" # If not set, is actually set to bind-address. -#port = 4242 -#database = "opentsdb_database" - -# Configure UDP listener for series data. -[udp] -enabled = true -bind-address = "0.0.0.0" -port = 4444 - -# Broker configuration. Brokers are nodes which participate in distributed -# consensus. -[broker] -enabled = true -# Where the Raft logs are stored. The user running InfluxDB will need read/write access. -dir = "/var/opt/influxdb/raft" -truncation-interval = "10m" -max-topic-size = 52428800 -max-segment-size = 10485760 - -# Raft configuration. Controls the distributed consensus system. -[raft] -apply-interval = "10ms" -election-timeout = "5s" -heartbeat-interval = "100ms" -reconnect-timeout = "10ms" - -# Data node configuration. Data nodes are where the time-series data, in the form of -# shards, is stored. [data] -enabled = true -dir = "/var/opt/influxdb/db" + dir = "/var/opt/influxdb/data" + retention-auto-create = true + retention-check-enabled = true + retention-check-period = "10m0s" + retention-create-period = "45m0s" -# Auto-create a retention policy when a database is created. Defaults to true. -retention-auto-create = true +[cluster] + shard-writer-timeout = "5s" -# Control whether retention policies are enforced and how long the system waits between -# enforcing those policies. -retention-check-enabled = true -retention-check-period = "10m" +[retention] + enabled = true + check-interval = "10m0s" -# Configuration for snapshot endpoint. -[snapshot] -enabled = true # Enabled by default if not set. +[admin] + enabled = true + bind-address = ":8083" -[logging] -write-tracing = false # If true, enables detailed logging of the write system. -raft-tracing = false # If true, enables detailed logging of Raft consensus. -http-access = true # If true, logs each HTTP access to the system. +[http] + enabled = true + bind-address = ":8086" + auth-enabled = false + log-enabled = true + write-tracing = false + pprof-enabled = false + +[collectd] + enabled = false + bind-address = "" + database = "" + typesdb = "" + +[opentsdb] + enabled = false + bind-address = "" + database = "" + retention-policy = "" + +[udp] + enabled = true + bind-address = ":4444" + database = "udp.test" + batch-size = 0 + batch-timeout = "10ns" -# InfluxDB can store statistical and diagnostic information about itself. This is useful for -# monitoring purposes. This feature is disabled by default, but if enabled, these data can be -# queried like any other data. [monitoring] -enabled = false -write-interval = "1m" # Period between writing the data. + enabled = false + write-interval = "1m0s" + +[continuous_queries] + enabled = true + recompute-previous-n = 2 + recompute-no-older-than = "10m0s" + compute-runs-per-interval = 10 + compute-no-more-than = "2m0s" + +[hinted-handoff] + enabled = true + dir = "/var/opt/influxdb/hh" + max-size = 1073741824 + max-age = "168h0m0s" + retry-rate-limit = 0 + retry-interval = "1s" + diff --git a/src/InfluxDB/Adapter/AdapterAbstract.php b/src/InfluxDB/Adapter/AdapterAbstract.php index f933c866b..b03d47681 100644 --- a/src/InfluxDB/Adapter/AdapterAbstract.php +++ b/src/InfluxDB/Adapter/AdapterAbstract.php @@ -28,6 +28,7 @@ abstract class AdapterAbstract implements AdapterInterface return [ "database" => $this->getOptions()->getDatabase(), "retentionPolicy" => $this->getOptions()->getRetentionPolicy(), + "tags" => $this->getOptions()->getTags(), ]; } diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/InfluxDB/Adapter/GuzzleAdapter.php index 9a4d1ab78..96b861158 100644 --- a/src/InfluxDB/Adapter/GuzzleAdapter.php +++ b/src/InfluxDB/Adapter/GuzzleAdapter.php @@ -25,6 +25,10 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface { $message = array_replace_recursive($this->getMessageDefaults(), $message); + if (!count($message["tags"])) { + unset($message["tags"]); + } + $httpMessage = [ "auth" => [$this->getOptions()->getUsername(), $this->getOptions()->getPassword()], "body" => json_encode($message) diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/InfluxDB/Adapter/UdpAdapter.php index 39a9a7570..fb9519dff 100644 --- a/src/InfluxDB/Adapter/UdpAdapter.php +++ b/src/InfluxDB/Adapter/UdpAdapter.php @@ -8,10 +8,67 @@ final class UdpAdapter extends AdapterAbstract public function send(array $message) { $message = array_replace_recursive($this->getMessageDefaults(), $message); + $message = $this->serialize($message); - $message = json_encode($message); + $this->write($message); + } + + public function write($message) + { $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_sendto($socket, $message, strlen($message), 0, $this->getOptions()->getHost(), $this->getOptions()->getPort()); socket_close($socket); } + + private function serialize(array $message) + { + $tags = $this->getOptions()->getTags(); + + if (array_key_exists("tags", $message)) { + $tags = array_replace_recursive($tags, $message["tags"]); + } + + $unixepoch = (int)microtime(true); + if (array_key_exists("time", $message)) { + $dt = new \DateTime($message["time"]); + $unixepoch = $dt->format("U"); + } + + $lines = []; + foreach ($message["points"] as $point) { + if (array_key_exists("tags", $point)) { + $tags = array_replace_recursive($tags, $point["tags"]); + } + + if (!$tags) { + $lines[] = trim( + sprintf( + "%s %s %d", + $point["measurement"], $this->toKeyValue($point["fields"], true), $unixepoch + ) + ); + } else { + $lines[] = trim( + sprintf( + "%s,%s %s %d", + $point["measurement"], $this->toKeyValue($tags), $this->toKeyValue($point["fields"], true), $unixepoch + ) + ); + } + } + return implode("\n", $lines); + } + + private function toKeyValue(array $elems, $escape=false) + { + $list = []; + foreach ($elems as $key => $value) { + if ($escape && is_string($value)) { + $value = "\"{$value}\""; + } + $list[] = sprintf("%s=%s", $key, $value); + } + + return implode(",", $list); + } } diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index bfaf09fa0..057ddf12e 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -29,7 +29,7 @@ class Client if (!is_array($name)) { $data =[]; - $data['points'][0]['name'] = $name; + $data['points'][0]['measurement'] = $name; $data['points'][0]['fields'] = $values; } diff --git a/src/InfluxDB/Options.php b/src/InfluxDB/Options.php index 3b4693b25..1d030f8db 100644 --- a/src/InfluxDB/Options.php +++ b/src/InfluxDB/Options.php @@ -7,41 +7,22 @@ namespace InfluxDB; */ class Options { - /** - * @var string - */ private $host; - /** - * @var string|int - */ private $port; - /** - * @var string - */ private $username; - /** - * @var string - */ private $password; - /** - * @var string - */ private $protocol; - /** - * @var string - */ private $database; private $retentionPolicy; - /** - * Set default options - */ + private $tags; + public function __construct() { $this->setHost("localhost"); @@ -51,6 +32,18 @@ class Options $this->setProtocol("http"); $this->setRetentionPolicy("default"); + $this->setTags([]); + } + + public function getTags() + { + return $this->tags; + } + + public function setTags($tags) + { + $this->tags = $tags; + return $this; } public function getRetentionPolicy() diff --git a/tests/InfluxDB/Adapter/UdpAdapterTest.php b/tests/InfluxDB/Adapter/UdpAdapterTest.php new file mode 100644 index 000000000..06e59b820 --- /dev/null +++ b/tests/InfluxDB/Adapter/UdpAdapterTest.php @@ -0,0 +1,64 @@ +getMethod("serialize"); + $method->setAccessible(true); + + $message = $method->invokeArgs($object, [$input]); + + $this->assertEquals($response, $message); + } + + public function getMessages() + { + return [ + [ + [ + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "cpu", + "fields" => [ + "value" => 1, + ], + ], + ], + ], + "cpu value=1 1257894000" + ], + [ + [ + "tags" => [ + "region" => "us-west", + "host" => "serverA", + "env" => "prod", + "target" => "servers", + "zone" => "1c", + ], + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "cpu", + "fields" => [ + "cpu" => 18.12, + "free" => 712432, + ], + ], + ], + ], + "cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000" + ] + ]; + } +} diff --git a/tests/InfluxDB/ClientTest.php b/tests/InfluxDB/ClientTest.php index 27a42773d..6d8aff01a 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/InfluxDB/ClientTest.php @@ -108,7 +108,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase ], "points" => [ [ - "name" => "vm-serie", + "measurement" => "vm-serie", "fields" => [ "cpu" => 18.12, "free" => 712423, @@ -126,6 +126,37 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); } + /** + * @group tcp + */ + public function testOverrideDatabaseNameViaMessage() + { + $this->options->setDatabase("a-wrong-database"); + + $this->object->mark([ + "database" => "tcp.test", + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + sleep(1); + + $this->options->setDatabase("tcp.test"); + $body = $this->object->query("select * from \"vm-serie\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); + $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); + } + /** * @group udp */ @@ -144,60 +175,20 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object->setAdapter($adapter); $object->mark("udp.test", ["mark" => "element"]); + sleep(1); $object->mark("udp.test", ["mark" => "element1"]); + sleep(1); $object->mark("udp.test", ["mark" => "element2"]); + sleep(1); $object->mark("udp.test", ["mark" => "element3"]); // Wait UDP/IP message arrives - sleep(1); + sleep(2); $this->options->setDatabase("udp.test"); $body = $this->object->query("select * from \"udp.test\""); $this->assertCount(4, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group udp - */ - public function testOverrideDatabaseNameViaMessage() - { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost($rawOptions["udp"]["host"]); - $options->setUsername($rawOptions["udp"]["username"]); - $options->setPassword($rawOptions["udp"]["password"]); - $options->setPort($rawOptions["udp"]["port"]); - $options->setDatabase("a-wrong-database"); - - $adapter = new UdpAdapter($options); - $object = new Client(); - $object->setAdapter($adapter); - - $object->mark([ - "database" => "{$rawOptions["udp"]["database"]}", - "points" => [ - [ - "name" => "vm-serie", - "fields" => [ - "cpu" => 18.12, - "free" => 712423, - ], - ], - ] - ]); - - sleep(1); - - $this->options->setDatabase($rawOptions["udp"]["database"]); - $body = $this->object->query("select * from \"vm-serie\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); - $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); } /** @@ -220,7 +211,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object->mark([ "points" => [ [ - "name" => "vm-serie", + "measurement" => "vm-serie", "fields" => [ "cpu" => 18.12, "free" => 712423, @@ -229,7 +220,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase ] ]); - sleep(1); + sleep(2); $this->options->setDatabase("udp.test"); $body = $this->object->query("select * from \"vm-serie\""); @@ -264,7 +255,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase ], "points" => [ [ - "name" => "vm-serie", + "measurement" => "vm-serie", "tags" => [ "dc" => "eu-west-1", "one" => "two", @@ -275,7 +266,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase ], ], [ - "name" => "vm-serie", + "measurement" => "vm-serie", "tags" => [ "dc" => "us-east-1", ], @@ -287,7 +278,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase ] ]); - sleep(1); + sleep(2); $this->options->setDatabase("udp.test"); $body = $this->object->query("select * from \"vm-serie\" where dc='eu-west-1'"); From 270154fd946bcd357922521a5b789ab022d3f18f Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 11:47:38 +0200 Subject: [PATCH 085/158] Updated docs --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/README.md b/README.md index f453099d9..20c37c5e8 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,59 @@ array(1) { } ``` +## UDP/IP support + +As you know InfluxDB support UDP/IP using a "line protocol", that is a string +line, like: + +``` +cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000 +``` + +More points could be added and are separated by commas. + +In order to simplify the SDK operations you will use a single format: + +**Concise Format** + +```php +$client->mark("serie-name", [ + "power" => 124.21, + "voltage" => 12.4, +]); +``` + +**Extended Format** + +```php +$client->mark([ + "tags" => [ + "region" => "us-west", + "host" => "serverA", + "env" => "prod", + "target" => "servers", + "zone" => "1c", + ], + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "cpu", + "fields" => [ + "cpu" => 18.12, + "free" => 712432, + ], + ], + ], +]); +``` + +If you want to use the inline protocol directly you have to use the UDP/IP adapter directly + +``` +$udp = new UdpAdapter($options); +$udp->write("cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000"); +``` + ## Database operations You can create, list or destroy databases using dedicated methods From 4f94172fcbc275542d5c91ade46568827567929d Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 13:38:04 +0200 Subject: [PATCH 086/158] Rename data provider with a more valid name --- tests/InfluxDB/ClientFactoryTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/InfluxDB/ClientFactoryTest.php b/tests/InfluxDB/ClientFactoryTest.php index 6d61c8960..e89d6d866 100644 --- a/tests/InfluxDB/ClientFactoryTest.php +++ b/tests/InfluxDB/ClientFactoryTest.php @@ -51,7 +51,7 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase /** * @group factory * @group tcp - * @dataProvider getTcpAdapters + * @dataProvider getHttpAdapters */ public function testCreateTcpClient($adapter) { @@ -75,16 +75,9 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); } - public function getTcpAdapters() - { - return [ - ["InfluxDB\\Adapter\\GuzzleAdapter"], - ]; - } - /** * @group factory - * @dataProvider getTcpAdapters + * @dataProvider getHttpAdapters */ public function testCreateTcpClientWithFilter($adapter) { @@ -107,4 +100,11 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); } + + public function getHttpAdapters() + { + return [ + ["InfluxDB\\Adapter\\GuzzleAdapter"], + ]; + } } From 5a162a97040c761d96e0a182013b916dded2471e Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 13:41:06 +0200 Subject: [PATCH 087/158] Added tests for global tags and retention policies --- tests/InfluxDB/ClientFactoryTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/InfluxDB/ClientFactoryTest.php b/tests/InfluxDB/ClientFactoryTest.php index e89d6d866..a7f0e44f1 100644 --- a/tests/InfluxDB/ClientFactoryTest.php +++ b/tests/InfluxDB/ClientFactoryTest.php @@ -79,7 +79,7 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase * @group factory * @dataProvider getHttpAdapters */ - public function testCreateTcpClientWithFilter($adapter) + public function testCreateTcpClientWithAllOptions($adapter) { $options = [ "adapter" => [ @@ -89,6 +89,11 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase "host" => "127.0.0.1", "username" => "user", "password" => "pass", + "retention_policy" => "too_many_data", + "tags" => [ + "region" => "eu", + "env" => "prod", + ], ], ]; @@ -99,6 +104,8 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals("127.0.0.1", $client->getAdapter()->getOptions()->getHost()); $this->assertEquals("user", $client->getAdapter()->getOptions()->getUsername()); $this->assertEquals("pass", $client->getAdapter()->getOptions()->getPassword()); + $this->assertEquals(["region" => "eu", "env" => "prod"], $client->getAdapter()->getOptions()->getTags()); + $this->assertEquals("too_many_data", $client->getAdapter()->getOptions()->getRetentionPolicy()); } public function getHttpAdapters() From 654b2c7e88b2fa7329d6e0a45b774ffbb1d7c5ad Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 13:55:22 +0200 Subject: [PATCH 088/158] Updated docs --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 20c37c5e8..adabeb480 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ Send metrics to InfluxDB and query for any data. **For InfluxDB v0.8 checkout branch 0.3** +Supported adapters: + + * HTTP + * UDP/IP + ## Install it Just use composer @@ -72,7 +77,6 @@ Actually we supports two adapters ### Using UDP/IP Adapter - In order to use the UDP/IP adapter your must have PHP compiled with the `sockets` extension. To verify if you have the `sockets` extension just issue a: @@ -83,8 +87,9 @@ php -m | grep sockets If you don't have the `sockets` extension, you can proceed in two ways: -- Recompile your PHP whith the `--enable-sockets` flag -- Or just compile the `sockets` extension extracting it from the PHP source. + - Recompile your PHP whith the `--enable-sockets` flag + - Or just compile the `sockets` extension extracting it from the PHP source. + 1. Download the source relative to the PHP version that you on from [here](https://github.com/php/php-src/releases) 2. Enter in the `ext/sockets` directory 3. Issue a `phpize && ./configure && make -j && sudo make install` @@ -109,7 +114,7 @@ Actually Guzzle is used as HTTP client library $http = new \GuzzleHttp\Client(); $options = new Options(); -$adapter = new HttpAdapter($http, $options); +$adapter = new GuzzleAdapter($http, $options); $client = new Client(); $client->setAdapter($adapter); @@ -131,6 +136,11 @@ $options = [ "options" => [ "host" => "my.influx.domain.tld", "db" => "mydb", + "retention_policy" => "myPolicy", + "tags" => [ + "env" => "prod", + "app" => "myApp", + ], ] ]; $client = \InfluxDB\ClientFactory::create($options); @@ -236,17 +246,41 @@ $client->deleteDatabase("my.name"); // delete an existing database with name "my Actually only queryable adapters can handle databases (implements the `QueryableInterface`) +## Global tags and retention policy + +You can set a set of default tags, that the SDK will add to your metrics: + +```php +$options = new Options(); +$options->setTags([ + "env" => "prod", + "region" => "eu-west-1", +]); +``` + +The SDK mark all point adding those tags. + +You can set a default retentionPolicy using + +``` +$options->setRetentionPolicy("myPolicy"); +``` + +In that way the SDK use that policy instead of `default` policy. + ## Benchmarks +Simple benchmarks executed on a Sony Vaio T13 (SVT1311C5E) + ### Adapters -The impact using UDP or HTTP adapters +The impact using UDP/IP or HTTP adapters ``` Corley\Benchmarks\InfluxDB\AdapterEvent Method Name Iterations Average Time Ops/second ------------------------ ------------ -------------- ------------- - sendDataUsingHttpAdapter: [1,000 ] [0.0098177127838] [101.85672] - sendDataUsingUdpAdapter : [1,000 ] [0.0000694372654] [14,401.48880] + sendDataUsingHttpAdapter: [1,000 ] [0.0162619416714] [61.49327] + sendDataUsingUdpAdapter : [1,000 ] [0.0000890662670] [11,227.59529] ``` From 6f8045472569ca62fd99ebd55a5aae98c1606e99 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 13:56:33 +0200 Subject: [PATCH 089/158] Removed exceptions --- src/InfluxDB/Exception/InfluxAuthorizationException.php | 9 --------- src/InfluxDB/Exception/InfluxBadResponseException.php | 9 --------- src/InfluxDB/Exception/InfluxGeneralException.php | 9 --------- src/InfluxDB/Exception/InfluxNoSeriesException.php | 9 --------- .../Exception/InfluxUnexpectedResponseException.php | 9 --------- 5 files changed, 45 deletions(-) delete mode 100644 src/InfluxDB/Exception/InfluxAuthorizationException.php delete mode 100644 src/InfluxDB/Exception/InfluxBadResponseException.php delete mode 100644 src/InfluxDB/Exception/InfluxGeneralException.php delete mode 100644 src/InfluxDB/Exception/InfluxNoSeriesException.php delete mode 100644 src/InfluxDB/Exception/InfluxUnexpectedResponseException.php diff --git a/src/InfluxDB/Exception/InfluxAuthorizationException.php b/src/InfluxDB/Exception/InfluxAuthorizationException.php deleted file mode 100644 index 83dcd32c7..000000000 --- a/src/InfluxDB/Exception/InfluxAuthorizationException.php +++ /dev/null @@ -1,9 +0,0 @@ - Date: Wed, 10 Jun 2015 14:02:09 +0200 Subject: [PATCH 090/158] License to 2015 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index a29931ccd..db1e02eeb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014 Corley S.r.l. +Copyright (c) 2015 Corley S.r.l. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 9db35097e285e5b689076687e7b2222df547fe8f Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 14:00:20 +0200 Subject: [PATCH 091/158] Moved to PSR-4 Autoload from PSR-0 to PSR-4 --- .../{Corley => }/Benchmarks/InfluxDB/AdapterEvent.php | 0 composer.json | 9 +++++++-- src/{InfluxDB => }/Adapter/AdapterAbstract.php | 0 src/{InfluxDB => }/Adapter/AdapterInterface.php | 0 src/{InfluxDB => }/Adapter/GuzzleAdapter.php | 0 src/{InfluxDB => }/Adapter/QueryableInterface.php | 0 src/{InfluxDB => }/Adapter/UdpAdapter.php | 0 src/{InfluxDB => }/Client.php | 0 src/{InfluxDB => }/ClientFactory.php | 0 src/{InfluxDB => }/Options.php | 0 tests/{InfluxDB => }/Adapter/UdpAdapterTest.php | 0 tests/{InfluxDB => }/ClientFactoryTest.php | 0 tests/{InfluxDB => }/ClientTest.php | 2 +- 13 files changed, 8 insertions(+), 3 deletions(-) rename benchmarks/{Corley => }/Benchmarks/InfluxDB/AdapterEvent.php (100%) rename src/{InfluxDB => }/Adapter/AdapterAbstract.php (100%) rename src/{InfluxDB => }/Adapter/AdapterInterface.php (100%) rename src/{InfluxDB => }/Adapter/GuzzleAdapter.php (100%) rename src/{InfluxDB => }/Adapter/QueryableInterface.php (100%) rename src/{InfluxDB => }/Adapter/UdpAdapter.php (100%) rename src/{InfluxDB => }/Client.php (100%) rename src/{InfluxDB => }/ClientFactory.php (100%) rename src/{InfluxDB => }/Options.php (100%) rename tests/{InfluxDB => }/Adapter/UdpAdapterTest.php (100%) rename tests/{InfluxDB => }/ClientFactoryTest.php (100%) rename tests/{InfluxDB => }/ClientTest.php (99%) diff --git a/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php b/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php similarity index 100% rename from benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php rename to benchmarks/Benchmarks/InfluxDB/AdapterEvent.php diff --git a/composer.json b/composer.json index 0ba459dba..7c0fce5de 100644 --- a/composer.json +++ b/composer.json @@ -31,11 +31,16 @@ } ], "autoload": { - "psr-0": { - "InfluxDB\\": ["./src/", "./tests"], + "psr-4": { + "InfluxDB\\": ["./src/"], "Corley\\": ["./benchmarks/"] } }, + "autoload-dev": { + "psr-4": { + "InfluxDB\\": ["./tests/"] + } + }, "suggest": { "fabpot/pimple": "Allows to prepare the client dependencies in order to require an initialized instance", "zendframework/zend-servicemanager": "Use a service locator in order to prepare a valid instance", diff --git a/src/InfluxDB/Adapter/AdapterAbstract.php b/src/Adapter/AdapterAbstract.php similarity index 100% rename from src/InfluxDB/Adapter/AdapterAbstract.php rename to src/Adapter/AdapterAbstract.php diff --git a/src/InfluxDB/Adapter/AdapterInterface.php b/src/Adapter/AdapterInterface.php similarity index 100% rename from src/InfluxDB/Adapter/AdapterInterface.php rename to src/Adapter/AdapterInterface.php diff --git a/src/InfluxDB/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php similarity index 100% rename from src/InfluxDB/Adapter/GuzzleAdapter.php rename to src/Adapter/GuzzleAdapter.php diff --git a/src/InfluxDB/Adapter/QueryableInterface.php b/src/Adapter/QueryableInterface.php similarity index 100% rename from src/InfluxDB/Adapter/QueryableInterface.php rename to src/Adapter/QueryableInterface.php diff --git a/src/InfluxDB/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php similarity index 100% rename from src/InfluxDB/Adapter/UdpAdapter.php rename to src/Adapter/UdpAdapter.php diff --git a/src/InfluxDB/Client.php b/src/Client.php similarity index 100% rename from src/InfluxDB/Client.php rename to src/Client.php diff --git a/src/InfluxDB/ClientFactory.php b/src/ClientFactory.php similarity index 100% rename from src/InfluxDB/ClientFactory.php rename to src/ClientFactory.php diff --git a/src/InfluxDB/Options.php b/src/Options.php similarity index 100% rename from src/InfluxDB/Options.php rename to src/Options.php diff --git a/tests/InfluxDB/Adapter/UdpAdapterTest.php b/tests/Adapter/UdpAdapterTest.php similarity index 100% rename from tests/InfluxDB/Adapter/UdpAdapterTest.php rename to tests/Adapter/UdpAdapterTest.php diff --git a/tests/InfluxDB/ClientFactoryTest.php b/tests/ClientFactoryTest.php similarity index 100% rename from tests/InfluxDB/ClientFactoryTest.php rename to tests/ClientFactoryTest.php diff --git a/tests/InfluxDB/ClientTest.php b/tests/ClientTest.php similarity index 99% rename from tests/InfluxDB/ClientTest.php rename to tests/ClientTest.php index 6d8aff01a..ae08c5ca3 100644 --- a/tests/InfluxDB/ClientTest.php +++ b/tests/ClientTest.php @@ -16,7 +16,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase public function setUp() { - $options = include __DIR__ . '/../bootstrap.php'; + $options = include __DIR__ . '/bootstrap.php'; $this->rawOptions = $options; $tcpOptions = $options["tcp"]; From f95e32e150c8958fc20e4ff9360f90e221da879e Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 14:16:56 +0200 Subject: [PATCH 092/158] Removed bootstrap from phpunit.xml It was not a bootstrap file --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 445587fb6..64303a46a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,6 @@ Date: Wed, 10 Jun 2015 14:28:29 +0200 Subject: [PATCH 093/158] Bench inline protocol conversion --- README.md | 16 ++++ .../InfluxDB/MessageToInlineProtocolEvent.php | 92 +++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php diff --git a/README.md b/README.md index adabeb480..e92f50a07 100644 --- a/README.md +++ b/README.md @@ -284,3 +284,19 @@ Corley\Benchmarks\InfluxDB\AdapterEvent sendDataUsingUdpAdapter : [1,000 ] [0.0000890662670] [11,227.59529] ``` +### Message to inline protocol conversion + +As you know the SDK will provide a single interface in order to send data to +InfluxDB (concise or expanded). + +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] +``` + diff --git a/benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php b/benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php new file mode 100644 index 000000000..4bfce6ee9 --- /dev/null +++ b/benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php @@ -0,0 +1,92 @@ +getMethod("serialize"); + $method->setAccessible(true); + + $this->method = $method; + $this->object = $object; + } + + /** + * @iterations 10000 + */ + public function convertMessageToInlineProtocolWithNoTags() + { + $this->method->invokeArgs($this->object, [ + [ + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ] + ]); + } + + /** + * @iterations 10000 + */ + public function convertMessageToInlineProtocolWithGlobalTags() + { + $this->method->invokeArgs($this->object, [ + [ + "tags" => [ + "dc" => "eu-west-1", + ], + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ] + ]); + } + + /** + * @iterations 10000 + */ + public function convertMessageToInlineProtocolWithDifferentTagLevels() + { + $this->method->invokeArgs($this->object, [ + [ + "tags" => [ + "dc" => "eu-west-1", + ], + "points" => [ + [ + "measurement" => "vm-serie", + "tags" => [ + "server" => "tc12", + ], + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ] + ]); + } +} From 048e308bc9365c9a61faf1b3a8d6d80e96a06394 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 14:53:31 +0200 Subject: [PATCH 094/158] Test also multiple measurement with UDP/IP --- tests/Adapter/UdpAdapterTest.php | 32 +++++++++++++++++++- tests/ClientTest.php | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/tests/Adapter/UdpAdapterTest.php b/tests/Adapter/UdpAdapterTest.php index 06e59b820..4fe4b0b8c 100644 --- a/tests/Adapter/UdpAdapterTest.php +++ b/tests/Adapter/UdpAdapterTest.php @@ -58,7 +58,37 @@ class UdpAdapterTest extends \PHPUnit_Framework_TestCase ], ], "cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000" - ] + ], + [ + [ + "tags" => [ + "region" => "us-west", + "host" => "serverA", + "env" => "prod", + "target" => "servers", + "zone" => "1c", + ], + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "cpu", + "fields" => [ + "cpu" => 18.12, + ], + ], + [ + "measurement" => "mem", + "fields" => [ + "free" => 712432, + ], + ], + ], + ], + <<assertCount(4, $body["results"][0]["series"][0]["values"]); } + /** + * @group udp + */ + public function testSendMultipleMeasurementWithUdpIp() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setHost($rawOptions["udp"]["host"]); + $options->setUsername($rawOptions["udp"]["username"]); + $options->setPassword($rawOptions["udp"]["password"]); + $options->setPort($rawOptions["udp"]["port"]); + $options->setDatabase($rawOptions["udp"]["database"]); + + $adapter = new UdpAdapter($options); + $object = new Client(); + $object->setAdapter($adapter); + + $object->mark([ + "points" => [ + [ + "measurement" => "mem", + "fields" => [ + "free" => 712423, + ], + ], + [ + "measurement" => "cpu", + "fields" => [ + "cpu" => 18.12, + ], + ], + ] + ]); + + sleep(2); + + $this->options->setDatabase("udp.test"); + $body = $this->object->query("select * from \"cpu\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); + + $body = $this->object->query("select * from \"mem\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("free", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][1]); + } + /** * @group udp */ From f5a71a51a3aebcc11ee4e15820c03682d9538f91 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 14:59:01 +0200 Subject: [PATCH 095/158] Version 0.4.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1c09c74e2..1d0ba9ea1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.3 +0.4.0 From 38f65a75fddfb11b67e268b614e015950fdd60af Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 15:13:19 +0200 Subject: [PATCH 096/158] Client dependency with construction injection Removed the adapter setter injection in favor or constructor injection --- README.md | 28 ++++++++++++---------------- src/Client.php | 2 +- src/ClientFactory.php | 3 +-- tests/ClientTest.php | 15 +++++---------- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index e92f50a07..90e9bb1c4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Send metrics to InfluxDB and query for any data. -**For InfluxDB v0.8 checkout branch 0.3** +This project support InfluxDB API `>= 0.9` - **For InfluxDB v0.8 checkout branch 0.3** Supported adapters: @@ -45,13 +45,12 @@ Or use InfluxDB direct messages ```php $client->mark([ - "database" => "mydb", "tags" => [ "dc" => "eu-west-1", ], "points" => [ [ - "name" => "vm-serie", + "measurement" => "instance", "fields" => [ "cpu" => 18.12, "free" => 712423, @@ -65,15 +64,15 @@ $client->mark([ Retrieve existing points: ```php -$results = $client->query("select * from app.search"); +$results = $client->query('select * from "app.search"'); ``` ## InfluxDB client adapters -Actually we supports two adapters +Actually we supports two network adapters - * UDP/IP - in order to send data via UDP (datagram) - * HTTP JSON - in order to send/retrieve using HTTP (connection oriented) + * UDP/IP - in order to send data via UDP/IP (datagram) + * HTTP JSON - in order to send/retrieve using HTTP messages (connection oriented) ### Using UDP/IP Adapter @@ -120,7 +119,7 @@ $client = new Client(); $client->setAdapter($adapter); ``` -### Create your client with the factory method +## Create your client with the factory method Effectively the client creation is not so simple, for that reason you can you the factory method provided with the library. @@ -144,11 +143,9 @@ $options = [ ] ]; $client = \InfluxDB\ClientFactory::create($options); - -$client->mark("error.404", ["page" => "/a-missing-page"]); ``` -Of course you can always use the DiC or your service manager in order to create +Of course you can always use a DiC (eg `symfony/dependency-injection`) or your service manager in order to create a valid client instance. ### Query InfluxDB @@ -160,7 +157,7 @@ $influx->query('select * from "mine"'); ``` You can query the database only if the adapter is queryable (implements -`QueryableInterface`), actually `HttpAdapter`. +`QueryableInterface`), actually `GuzzleAdapter`. The adapter returns the json decoded body of the InfluxDB response, something like: @@ -182,16 +179,15 @@ array(1) { ## UDP/IP support -As you know InfluxDB support UDP/IP using a "line protocol", that is a string +As you know InfluxDB support UDP/IP with a "line protocol", that is a string line, like: ``` cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000 ``` -More points could be added and are separated by commas. - -In order to simplify the SDK operations you will use a single format: +In order to simplify the SDK usage, you will use a single method signature +for both adapters, UDP/IP and HTTP: **Concise Format** diff --git a/src/Client.php b/src/Client.php index 057ddf12e..e9f7c7d89 100644 --- a/src/Client.php +++ b/src/Client.php @@ -12,7 +12,7 @@ class Client { private $adapter; - public function setAdapter(Adapter\AdapterInterface $adapter) + public function __construct(Adapter\AdapterInterface $adapter) { $this->adapter = $adapter; return $this; diff --git a/src/ClientFactory.php b/src/ClientFactory.php index a9ea2dccb..33789ec8a 100644 --- a/src/ClientFactory.php +++ b/src/ClientFactory.php @@ -48,8 +48,7 @@ abstract class ClientFactory throw new \InvalidArgumentException("Missing adapter {$adapter}"); } - $client = new Client(); - $client->setAdapter($adapter); + $client = new Client($adapter); return $client; } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 3467749bf..c3f24cb4e 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -33,8 +33,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $guzzleHttp = new GuzzleHttpClient(); $adapter = new InfluxHttpAdapter($guzzleHttp, $options); - $influx = new Client(); - $influx->setAdapter($adapter); + $influx = new Client($adapter); $this->object = $influx; $databases = $this->object->getDatabases(); @@ -171,8 +170,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setDatabase($rawOptions["udp"]["database"]); $adapter = new UdpAdapter($options); - $object = new Client(); - $object->setAdapter($adapter); + $object = new Client($adapter); $object->mark("udp.test", ["mark" => "element"]); sleep(1); @@ -205,8 +203,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setDatabase($rawOptions["udp"]["database"]); $adapter = new UdpAdapter($options); - $object = new Client(); - $object->setAdapter($adapter); + $object = new Client($adapter); $object->mark([ "points" => [ @@ -255,8 +252,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setDatabase($rawOptions["udp"]["database"]); $adapter = new UdpAdapter($options); - $object = new Client(); - $object->setAdapter($adapter); + $object = new Client($adapter); $object->mark([ "points" => [ @@ -296,8 +292,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $options->setDatabase($rawOptions["udp"]["database"]); $adapter = new UdpAdapter($options); - $object = new Client(); - $object->setAdapter($adapter); + $object = new Client($adapter); $object->mark([ "tags" => [ From ff6f865d420e9cad5a699226eb48a13981bed515 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 15:19:41 +0200 Subject: [PATCH 097/158] Test refactoring Removed UDP/IP adapter construction (duplication) --- tests/ClientTest.php | 60 +++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index c3f24cb4e..f868a4cfc 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -161,16 +161,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testUdpIpWriteData() { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost($rawOptions["udp"]["host"]); - $options->setUsername($rawOptions["udp"]["username"]); - $options->setPassword($rawOptions["udp"]["password"]); - $options->setPort($rawOptions["udp"]["port"]); - $options->setDatabase($rawOptions["udp"]["database"]); - - $adapter = new UdpAdapter($options); - $object = new Client($adapter); + $object = $this->createClientWithUdpAdapter(); $object->mark("udp.test", ["mark" => "element"]); sleep(1); @@ -194,16 +185,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testSendMultipleMeasurementWithUdpIp() { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost($rawOptions["udp"]["host"]); - $options->setUsername($rawOptions["udp"]["username"]); - $options->setPassword($rawOptions["udp"]["password"]); - $options->setPort($rawOptions["udp"]["port"]); - $options->setDatabase($rawOptions["udp"]["database"]); - - $adapter = new UdpAdapter($options); - $object = new Client($adapter); + $object = $this->createClientWithUdpAdapter(); $object->mark([ "points" => [ @@ -243,16 +225,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testWriteDirectMessageWithUdpIp() { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost($rawOptions["udp"]["host"]); - $options->setUsername($rawOptions["udp"]["username"]); - $options->setPassword($rawOptions["udp"]["password"]); - $options->setPort($rawOptions["udp"]["port"]); - $options->setDatabase($rawOptions["udp"]["database"]); - - $adapter = new UdpAdapter($options); - $object = new Client($adapter); + $object = $this->createClientWithUdpAdapter(); $object->mark([ "points" => [ @@ -283,16 +256,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase */ public function testTagsAreWrittenCorrectly() { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost($rawOptions["udp"]["host"]); - $options->setUsername($rawOptions["udp"]["username"]); - $options->setPassword($rawOptions["udp"]["password"]); - $options->setPort($rawOptions["udp"]["port"]); - $options->setDatabase($rawOptions["udp"]["database"]); - - $adapter = new UdpAdapter($options); - $object = new Client($adapter); + $object = $this->createClientWithUdpAdapter(); $object->mark([ "tags" => [ @@ -353,4 +317,20 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->object->deleteDatabase("walter"); } + + private function createClientWithUdpAdapter() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setHost($rawOptions["udp"]["host"]); + $options->setUsername($rawOptions["udp"]["username"]); + $options->setPassword($rawOptions["udp"]["password"]); + $options->setPort($rawOptions["udp"]["port"]); + $options->setDatabase($rawOptions["udp"]["database"]); + + $adapter = new UdpAdapter($options); + $object = new Client($adapter); + + return $object; + } } From adece73b0bc4b3f6e6b2d58151bdbf3c8c0939c1 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 15:40:10 +0200 Subject: [PATCH 098/158] Fixes invalid saved timestamp for UDP/IP --- src/Adapter/UdpAdapter.php | 8 +++-- tests/ClientTest.php | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index fb9519dff..06477ed3b 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -1,6 +1,7 @@ format("U") * 1e9); if (array_key_exists("time", $message)) { - $dt = new \DateTime($message["time"]); - $unixepoch = $dt->format("U"); + $dt = new DateTime($message["time"]); + $unixepoch = (int)($dt->format("U") * 1e9); } $lines = []; diff --git a/tests/ClientTest.php b/tests/ClientTest.php index f868a4cfc..1bfb33db3 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -1,6 +1,7 @@ assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); } + /** + * @group udp + * @group date + */ + public function testWriteDirectMessageWillPreserveActualTime() + { + $object = $this->createClientWithUdpAdapter(); + + $object->mark([ + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + sleep(2); + + $this->options->setDatabase("udp.test"); + $body = $this->object->query("select * from \"vm-serie\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("time", $body["results"][0]["series"][0]["columns"][0]); + $saved = new DateTime($body["results"][0]["series"][0]["values"][0][0]); + $this->assertEquals(date("Y-m-d"), $saved->format("Y-m-d")); + } + + /** + * @group udp + * @group date + */ + public function testWriteDirectMessageWillPreserveDatetime() + { + $object = $this->createClientWithUdpAdapter(); + + $object->mark([ + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + sleep(2); + + $this->options->setDatabase("udp.test"); + $body = $this->object->query("select * from \"vm-serie\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("time", $body["results"][0]["series"][0]["columns"][0]); + $this->assertEquals("2009-11-10T23:00:00Z", $body["results"][0]["series"][0]["values"][0][0]); + } + /** * @group udp * @group tags From 245a911be825c8e6e178ea59677864c234db6f75 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 10 Jun 2015 15:45:24 +0200 Subject: [PATCH 099/158] Moved to InfluxDB RC33 --- .travis.yml | 4 ++-- tests/Adapter/UdpAdapterTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b0b653e2..fe9229a81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,9 @@ php: before_install: - sudo apt-get update - sudo apt-get install libcurl4-openssl-dev libjson0-dev - - wget http://get.influxdb.org/influxdb_0.9.0-rc32_amd64.deb + - wget http://get.influxdb.org/influxdb_0.9.0-rc33_amd64.deb - sudo useradd influxdb - - sudo dpkg -i influxdb_0.9.0-rc32_amd64.deb + - sudo dpkg -i influxdb_0.9.0-rc33_amd64.deb - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - travis_retry sudo service influxdb restart - sudo service influxdb status diff --git a/tests/Adapter/UdpAdapterTest.php b/tests/Adapter/UdpAdapterTest.php index 4fe4b0b8c..fa5908086 100644 --- a/tests/Adapter/UdpAdapterTest.php +++ b/tests/Adapter/UdpAdapterTest.php @@ -35,7 +35,7 @@ class UdpAdapterTest extends \PHPUnit_Framework_TestCase ], ], ], - "cpu value=1 1257894000" + "cpu value=1 1257894000000000000" ], [ [ @@ -57,7 +57,7 @@ class UdpAdapterTest extends \PHPUnit_Framework_TestCase ], ], ], - "cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000" + "cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000000000000" ], [ [ @@ -85,8 +85,8 @@ class UdpAdapterTest extends \PHPUnit_Framework_TestCase ], ], << Date: Wed, 10 Jun 2015 20:24:06 +0200 Subject: [PATCH 100/158] Minor fixes on docs --- README.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 90e9bb1c4..4a35a12e1 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,11 @@ Supported adapters: Just use composer -```shell -php composer.phar require corley/influxdb-sdk:dev-master -``` - -Or place it in your require section - ```json { "require": { // ... - "corley/influxdb-sdk": "dev-master" + "corley/influxdb-sdk": ">=0.4" } } ``` @@ -100,8 +94,7 @@ If you don't have the `sockets` extension, you can proceed in two ways: $options = new Options(); $adapter = new UdpAdapter($options); -$client = new Client(); -$client->setAdapter($adapter); +$client = new Client($adapter); ``` ### Using HTTP Adapters @@ -115,8 +108,7 @@ $http = new \GuzzleHttp\Client(); $options = new Options(); $adapter = new GuzzleAdapter($http, $options); -$client = new Client(); -$client->setAdapter($adapter); +$client = new Client($adapter); ``` ## Create your client with the factory method @@ -183,7 +175,7 @@ As you know InfluxDB support UDP/IP with a "line protocol", that is a string line, like: ``` -cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000 +cpu,region=us-west,env=prod,zone=1c cpu=18.12,free=712432 1257894000 ``` In order to simplify the SDK usage, you will use a single method signature From b02a6ef92e5f125913b87e3825df3b9735bf5408 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Jun 2015 22:23:50 +0200 Subject: [PATCH 101/158] Travis updated with vv0.9 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe9229a81..af9b34c6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,9 @@ php: before_install: - sudo apt-get update - sudo apt-get install libcurl4-openssl-dev libjson0-dev - - wget http://get.influxdb.org/influxdb_0.9.0-rc33_amd64.deb + - wget https://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb - sudo useradd influxdb - - sudo dpkg -i influxdb_0.9.0-rc33_amd64.deb + - sudo dpkg -i influxdb_latest_amd64.deb - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - travis_retry sudo service influxdb restart - sudo service influxdb status From ba4dc0af10fd79a129b22c2794ed02187c07d5f8 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 11 Jun 2015 22:24:22 +0200 Subject: [PATCH 102/158] Bumped version 0.4.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1d0ba9ea1..267577d47 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.0 +0.4.1 From 63b8bb4b893bbc23d33591ce5b2a5ed831e63f03 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Jun 2015 07:57:26 +0200 Subject: [PATCH 103/158] Fixes minor violations * Removed unsed `use` statemment * Moved helper http url composer to `GuzzleAdapter` (responsibility) * Removed unused `clearTimePrecision` method * Updated composer --- composer.lock | 46 +++++++++++++++++------------------ src/Adapter/GuzzleAdapter.php | 26 ++++++++++++++++++-- src/Adapter/UdpAdapter.php | 1 - src/Client.php | 15 ------------ src/Options.php | 22 ----------------- 5 files changed, 47 insertions(+), 63 deletions(-) diff --git a/composer.lock b/composer.lock index 805bb9737..40b847c1f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "96faa156d58fde5c5c3cf3df60d74ae1", + "hash": "61a6988d1b757bb9d3a074d156d73f9d", "packages": [ { "name": "guzzlehttp/guzzle", @@ -685,16 +685,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.1.3", + "version": "2.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c" + "reference": "be2286cb8c7e1773eded49d9719219e6f74f9e3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/28a6b34e91d789b2608072ab3c82eaae7cdb973c", - "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/be2286cb8c7e1773eded49d9719219e6f74f9e3e", + "reference": "be2286cb8c7e1773eded49d9719219e6f74f9e3e", "shasum": "" }, "require": { @@ -743,7 +743,7 @@ "testing", "xunit" ], - "time": "2015-06-03 07:01:01" + "time": "2015-06-09 13:05:42" }, { "name": "phpunit/php-file-iterator", @@ -931,16 +931,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.6.10", + "version": "4.7.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "7b5fe98b28302a8b25693b2298bca74463336975" + "reference": "41fea1e84ed84d373f5ac099a1276c4358c90708" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7b5fe98b28302a8b25693b2298bca74463336975", - "reference": "7b5fe98b28302a8b25693b2298bca74463336975", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/41fea1e84ed84d373f5ac099a1276c4358c90708", + "reference": "41fea1e84ed84d373f5ac099a1276c4358c90708", "shasum": "" }, "require": { @@ -951,7 +951,7 @@ "ext-spl": "*", "php": ">=5.3.3", "phpspec/prophecy": "~1.3,>=1.3.1", - "phpunit/php-code-coverage": "~2.0,>=2.0.11", + "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "~1.0", @@ -973,7 +973,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.6.x-dev" + "dev-master": "4.7.x-dev" } }, "autoload": { @@ -999,20 +999,20 @@ "testing", "xunit" ], - "time": "2015-06-03 05:03:30" + "time": "2015-06-11 16:20:25" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.3", + "version": "2.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7" + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7", - "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/92408bb1968a81b3217a6fdf6c1a198da83caa35", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35", "shasum": "" }, "require": { @@ -1054,7 +1054,7 @@ "mock", "xunit" ], - "time": "2015-05-29 05:19:18" + "time": "2015-06-11 15:55:48" }, { "name": "pimple/pimple", @@ -1475,16 +1475,16 @@ }, { "name": "symfony/yaml", - "version": "v2.7.0", + "version": "v2.7.1", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3" + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3", - "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", "shasum": "" }, "require": { @@ -1520,7 +1520,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:21:08" + "time": "2015-06-10 15:30:22" }, { "name": "zeptech/annotations", diff --git a/src/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php index 96b861158..2f5509bd9 100644 --- a/src/Adapter/GuzzleAdapter.php +++ b/src/Adapter/GuzzleAdapter.php @@ -34,7 +34,7 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface "body" => json_encode($message) ]; - $endpoint = $this->getOptions()->getHttpSeriesEndpoint(); + $endpoint = $this->getHttpSeriesEndpoint(); return $this->httpClient->post($endpoint, $httpMessage); } @@ -53,7 +53,29 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface private function get(array $httpMessage) { - $endpoint = $this->getOptions()->getHttpQueryEndpoint(); + $endpoint = $this->getHttpQueryEndpoint(); return $this->httpClient->get($endpoint, $httpMessage)->json(); } + + protected function getHttpSeriesEndpoint() + { + return sprintf( + "%s://%s:%d/write", + $this->getOptions()->getProtocol(), + $this->getOptions()->getHost(), + $this->getOptions()->getPort() + ); + } + + protected function getHttpQueryEndpoint($name = false) + { + $url = sprintf( + "%s://%s:%d/query", + $this->getOptions()->getProtocol(), + $this->getOptions()->getHost(), + $this->getOptions()->getPort() + ); + + return $url; + } } diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index 06477ed3b..bc9004ee3 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -2,7 +2,6 @@ namespace InfluxDB\Adapter; use DateTime; -use InfluxDB\Options; final class UdpAdapter extends AdapterAbstract { diff --git a/src/Client.php b/src/Client.php index e9f7c7d89..e1537ee84 100644 --- a/src/Client.php +++ b/src/Client.php @@ -3,7 +3,6 @@ namespace InfluxDB; use InfluxDb\Adapter\QueryableInterface; -use InfluxDB\Filter\FilterInterface; /** * Client to manage request at InfluxDB @@ -70,18 +69,4 @@ class Client } return $this->getAdapter()->query("drop database \"{$name}\""); } - - private function clearTimePrecision($timePrecision) - { - switch ($timePrecision) { - case 's': - case 'u': - case 'ms': - break; - default: - $timePrecision = false; - } - - return $timePrecision; - } } diff --git a/src/Options.php b/src/Options.php index 1d030f8db..c472c5235 100644 --- a/src/Options.php +++ b/src/Options.php @@ -125,26 +125,4 @@ class Options $this->database = $database; return $this; } - - public function getHttpSeriesEndpoint() - { - return sprintf( - "%s://%s:%d/write", - $this->getProtocol(), - $this->getHost(), - $this->getPort() - ); - } - - public function getHttpQueryEndpoint($name = false) - { - $url = sprintf( - "%s://%s:%d/query", - $this->getProtocol(), - $this->getHost(), - $this->getPort() - ); - - return $url; - } } From 473d21e9c86b7cccc07955b0fd5d3aa5629a2806 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Jun 2015 08:00:59 +0200 Subject: [PATCH 104/158] Bumped version 0.4.2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 267577d47..2b7c5ae01 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.1 +0.4.2 From c162760ab838dd62f96a08d9f1a6f95a8a0c8cba Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 11:04:11 +0200 Subject: [PATCH 105/158] Fixes time generation for udp/ip packets Uses microtimes instead of Datetime --- src/Adapter/UdpAdapter.php | 3 +-- tests/ClientTest.php | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index bc9004ee3..e497b13b7 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -28,8 +28,7 @@ final class UdpAdapter extends AdapterAbstract $tags = array_replace_recursive($tags, $message["tags"]); } - $now = new DateTime(); - $unixepoch = (int)($now->format("U") * 1e9); + $unixepoch = (int)(microtime(true) * 1e9); if (array_key_exists("time", $message)) { $dt = new DateTime($message["time"]); $unixepoch = (int)($dt->format("U") * 1e9); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 1bfb33db3..ad5367b2e 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -2,6 +2,7 @@ namespace InfluxDB; use DateTime; +use DateTimeZone; use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter; use InfluxDB\Options; use InfluxDB\Adapter\UdpAdapter; @@ -165,11 +166,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object = $this->createClientWithUdpAdapter(); $object->mark("udp.test", ["mark" => "element"]); - sleep(1); $object->mark("udp.test", ["mark" => "element1"]); - sleep(1); $object->mark("udp.test", ["mark" => "element2"]); - sleep(1); $object->mark("udp.test", ["mark" => "element3"]); // Wait UDP/IP message arrives @@ -278,8 +276,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertCount(1, $body["results"][0]["series"][0]["values"]); $this->assertEquals("time", $body["results"][0]["series"][0]["columns"][0]); - $saved = new DateTime($body["results"][0]["series"][0]["values"][0][0]); - $this->assertEquals(date("Y-m-d"), $saved->format("Y-m-d")); + $saved = $body["results"][0]["series"][0]["values"][0][0]; + $this->assertRegExp("/".date("Y-m-d")."/i", $saved); } /** From b2f044f15459027700befd01776b0e618d79e9a1 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 11:24:13 +0200 Subject: [PATCH 106/158] Bumped version 0.4.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2b7c5ae01..17b2ccd9b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.2 +0.4.3 From c52377aad1431aceb8868ccdc6bb82acb3774bbc Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 13 Jun 2015 12:04:04 +0200 Subject: [PATCH 107/158] 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 108/158] 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 109/158] 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 110/158] 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 111/158] 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 From b6767030e585eb44bbaadd1f12b6345f76f5c330 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Jun 2015 11:36:23 +0200 Subject: [PATCH 112/158] Minor on docs --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d5171146..5c58daaad 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,12 @@ Just use composer } ``` +## Use it + Add new points: ```php -$client->mark("app.search", [ +$client->mark("app-search", [ "key" => "this is my search" ]); ``` @@ -54,11 +56,10 @@ $client->mark([ ]); ``` - Retrieve existing points: ```php -$results = $client->query('select * from "app.search"'); +$results = $client->query('select * from "app-search"'); ``` ## InfluxDB client adapters From e4c38883ad0a5ee9b7a20744c625098f1d36921e Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Jun 2015 11:46:00 +0200 Subject: [PATCH 113/158] Removed senso insight (shows no medal when kudos) --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 5c58daaad..35fbd43d6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # InfluxDB PHP SDK -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/699a9a78-39aa-41d0-bb60-41dbf0f1251d/big.png)](https://insight.sensiolabs.com/projects/699a9a78-39aa-41d0-bb60-41dbf0f1251d) - * Master: [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) * Develop: [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=develop)](https://travis-ci.org/corley/influxdb-php-sdk) From 06fe10bc9d75c6a580ff4d24b9a4d13203eff386 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Jun 2015 11:49:27 +0200 Subject: [PATCH 114/158] Moved sockets compile section to bottom --- README.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 35fbd43d6..bd9a47b19 100644 --- a/README.md +++ b/README.md @@ -71,22 +71,6 @@ Actually we supports two network adapters In order to use the UDP/IP adapter your must have PHP compiled with the `sockets` extension. -To verify if you have the `sockets` extension just issue a: - -```bash -php -m | grep sockets -``` - -If you don't have the `sockets` extension, you can proceed in two ways: - - - Recompile your PHP whith the `--enable-sockets` flag - - Or just compile the `sockets` extension extracting it from the PHP source. - - 1. Download the source relative to the PHP version that you on from [here](https://github.com/php/php-src/releases) - 2. Enter in the `ext/sockets` directory - 3. Issue a `phpize && ./configure && make -j && sudo make install` - 4. Add `extension=sockets.so` to your php.ini - **Usage** ```php @@ -287,3 +271,23 @@ Corley\Benchmarks\InfluxDB\MessageToInlineProtocolEvent convertMessageToInlineProtocolWithDifferentTagLevels: [10,000 ] [0.0000343942404] [29,074.63543] ``` +## FAQ + +### Add sockets support to your PHP + +To verify if you have the `sockets` extension just issue a: + +```bash +php -m | grep sockets +``` + +If you don't have the `sockets` extension, you can proceed in two ways: + + - Recompile your PHP whith the `--enable-sockets` flag + - Or just compile the `sockets` extension extracting it from the PHP source. + + 1. Download the source relative to the PHP version that you on from [here](https://github.com/php/php-src/releases) + 2. Enter in the `ext/sockets` directory + 3. Issue a `phpize && ./configure && make -j && sudo make install` + 4. Add `extension=sockets.so` to your php.ini + From c04de6d075cec6f42731d0579fdce2fde36cf106 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 14 Jun 2015 11:51:04 +0200 Subject: [PATCH 115/158] Bumped version 0.4.5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6f2743d65..0bfccb080 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.4 +0.4.5 From 308aba881732333da80adb4a122ca6eebd417b29 Mon Sep 17 00:00:00 2001 From: Evan Darwin Date: Sat, 20 Jun 2015 13:03:09 -0700 Subject: [PATCH 116/158] Silently handle socket errors in the UdpAdapter (closes #27), add testcase --- src/Adapter/UdpAdapter.php | 9 +++++++++ tests/ClientTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index e497b13b7..2f9930087 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -15,9 +15,18 @@ final class UdpAdapter extends AdapterAbstract public function write($message) { + // Create a handler in order to handle the 'Host is down' message + set_error_handler(function() { + // Suppress the error, this is the UDP adapter and if we can't send + // it then we shouldn't inturrupt their application. + }); + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_sendto($socket, $message, strlen($message), 0, $this->getOptions()->getHost(), $this->getOptions()->getPort()); socket_close($socket); + + // Remove our error handler. + restore_error_handler(); } private function serialize(array $message) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index ad5367b2e..34145d7ce 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -359,6 +359,30 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); } + /** + * Test that we handle socket problems correctly in the UDP + * adapter, and that they don't inturrupt the user's application. + * + * @group udp + */ + public function testReplicateIssue27() + { + $options = new \InfluxDB\Options(); + + // Configure options + $options->setHost('172.16.1.182'); + $options->setPort(4444); + $options->setDatabase('...'); + $options->setUsername('root'); + $options->setPassword('root'); + + $httpAdapter = new \InfluxDB\Adapter\UdpAdapter($options); + + $client = new \InfluxDB\Client(); + $client->setAdapter($httpAdapter); + $client->mark("udp.test", ["mark" => "element"]); + } + public function testListActiveDatabses() { $databases = $this->object->getDatabases(); From 6b46bf5c6b3b554933d6fd461b6d058a055c9e59 Mon Sep 17 00:00:00 2001 From: Evan Darwin Date: Sat, 20 Jun 2015 13:07:40 -0700 Subject: [PATCH 117/158] Fix issue #27 test --- tests/ClientTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 34145d7ce..840930317 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -378,8 +378,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $httpAdapter = new \InfluxDB\Adapter\UdpAdapter($options); - $client = new \InfluxDB\Client(); - $client->setAdapter($httpAdapter); + $client = new \InfluxDB\Client($httpAdapter); $client->mark("udp.test", ["mark" => "element"]); } From da239ecf8ed39b6c8c4c1f6fd759e7e9cc59ce12 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 21 Jun 2015 17:33:46 +0200 Subject: [PATCH 118/158] Allow URL prefixes This should fixes #34 --- .travis.yml | 4 ++++ scripts/nginx_proxy.conf | 25 +++++++++++++++++++++++++ src/Adapter/GuzzleAdapter.php | 10 ++++++---- src/Options.php | 14 ++++++++++++++ tests/ClientTest.php | 19 +++++++++++++++++++ 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 scripts/nginx_proxy.conf diff --git a/.travis.yml b/.travis.yml index af9b34c6d..72b9027c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,10 @@ before_install: - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - travis_retry sudo service influxdb restart - sudo service influxdb status + - sudo apt-get update + - sudo apt-get install -y nginx + - sudo cp scripts/nginx_proxy.conf /etc/nginx/conf.d/proxy.conf + - travis_retry sudo service nginx restart before_script: - composer selfupdate diff --git a/scripts/nginx_proxy.conf b/scripts/nginx_proxy.conf new file mode 100644 index 000000000..f92d10a30 --- /dev/null +++ b/scripts/nginx_proxy.conf @@ -0,0 +1,25 @@ +server { + listen 9000 default_server; + listen [::]:9000 default_server ipv6only=on; + + root /usr/share/nginx/html; + index index.html index.htm; + + server_name localhost; + + location / { + try_files $uri $uri/ =404; + } + + location /influxdb { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-NginX-Proxy true; + + rewrite ^/influxdb/?(.*) /$1 break; + + proxy_pass http://localhost:8086; + proxy_redirect off; + } +} diff --git a/src/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php index d55352101..35a3a6db4 100644 --- a/src/Adapter/GuzzleAdapter.php +++ b/src/Adapter/GuzzleAdapter.php @@ -54,20 +54,22 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface protected function getHttpSeriesEndpoint() { return sprintf( - "%s://%s:%d/write", + "%s://%s:%d%s/write", $this->getOptions()->getProtocol(), $this->getOptions()->getHost(), - $this->getOptions()->getPort() + $this->getOptions()->getPort(), + $this->getOptions()->getPrefix() ); } protected function getHttpQueryEndpoint($name = false) { $url = sprintf( - "%s://%s:%d/query", + "%s://%s:%d%s/query", $this->getOptions()->getProtocol(), $this->getOptions()->getHost(), - $this->getOptions()->getPort() + $this->getOptions()->getPort(), + $this->getOptions()->getPrefix() ); return $url; diff --git a/src/Options.php b/src/Options.php index c472c5235..15b1581f2 100644 --- a/src/Options.php +++ b/src/Options.php @@ -23,6 +23,8 @@ class Options private $tags; + private $prefix; + public function __construct() { $this->setHost("localhost"); @@ -30,11 +32,23 @@ class Options $this->setUsername("root"); $this->setPassword("root"); $this->setProtocol("http"); + $this->setPrefix(""); $this->setRetentionPolicy("default"); $this->setTags([]); } + public function getPrefix() + { + return $this->prefix; + } + + public function setPrefix($prefix) + { + $this->prefix = $prefix; + return $this; + } + public function getTags() { return $this->tags; diff --git a/tests/ClientTest.php b/tests/ClientTest.php index ad5367b2e..cad9201bf 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -64,6 +64,25 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); } + /** + * @group tcp + * @group proxy + */ + public function testGuzzleHttpApiWorksCorrectlyWithProxies() + { + $this->options->setHost("localhost"); + $this->options->setPort(9000); + $this->options->setPrefix("/influxdb"); + $this->object->mark("tcp.test", ["mark" => "element"]); + + sleep(2); + + $body = $this->object->query("select * from \"tcp.test\""); + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); + $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); + } + /** * @group tcp */ From a323409dbcd3f5b37f735f4c55c1621c08697636 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 21 Jun 2015 17:46:09 +0200 Subject: [PATCH 119/158] Added proxies in our doc file --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index bd9a47b19..b38953782 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,20 @@ $options->setRetentionPolicy("myPolicy"); In that way the SDK use that policy instead of `default` policy. +## Proxies and InfluxDB + +If you proxy your InfluxDB typically you have a prefix in your endpoints. + +``` +$option->setHost("proxy.influxdb.tld"); +$option->setPort(80); +$option->setPrefix("/influxdb"); // your prefix is: /influxdb + +// final url will be: http://proxy.influxdb.tld:80/influxdb/write + +$client->mark("serie", ["data" => "my-data"]); +``` + ## Benchmarks Simple benchmarks executed on a Sony Vaio T13 (SVT1311C5E) From 27c19c9e4b0528712e52769e60d1571c85a7aa69 Mon Sep 17 00:00:00 2001 From: Evan Darwin Date: Sat, 20 Jun 2015 13:07:40 -0700 Subject: [PATCH 120/158] Fix issue #27 test Conflicts: tests/ClientTest.php --- tests/ClientTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index cad9201bf..f44a2b1a0 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -378,6 +378,29 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); } + /** + * Test that we handle socket problems correctly in the UDP + * adapter, and that they don't inturrupt the user's application. + * + * @group udp + */ + public function testReplicateIssue27() + { + $options = new \InfluxDB\Options(); + + // Configure options + $options->setHost('172.16.1.182'); + $options->setPort(4444); + $options->setDatabase('...'); + $options->setUsername('root'); + $options->setPassword('root'); + + $httpAdapter = new \InfluxDB\Adapter\UdpAdapter($options); + + $client = new \InfluxDB\Client($httpAdapter); + $client->mark("udp.test", ["mark" => "element"]); + } + public function testListActiveDatabses() { $databases = $this->object->getDatabases(); From c6e7b744c309f5862b4bffe0236c72b3b868fd90 Mon Sep 17 00:00:00 2001 From: Evan Darwin Date: Sat, 20 Jun 2015 13:03:09 -0700 Subject: [PATCH 121/158] Silently handle socket errors in the UdpAdapter (closes #27), add testcase Conflicts: tests/ClientTest.php --- src/Adapter/UdpAdapter.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index e497b13b7..2f9930087 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -15,9 +15,18 @@ final class UdpAdapter extends AdapterAbstract public function write($message) { + // Create a handler in order to handle the 'Host is down' message + set_error_handler(function() { + // Suppress the error, this is the UDP adapter and if we can't send + // it then we shouldn't inturrupt their application. + }); + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_sendto($socket, $message, strlen($message), 0, $this->getOptions()->getHost(), $this->getOptions()->getPort()); socket_close($socket); + + // Remove our error handler. + restore_error_handler(); } private function serialize(array $message) From 8e57dd7eb22e231bbbbc417055db272e60e7b76b Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 21 Jun 2015 17:58:29 +0200 Subject: [PATCH 122/158] Bumped version 0.5.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0bfccb080..8f0916f76 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.5 +0.5.0 From 00ec4404992d73e154876fd2fe3a61db7aa3609f Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 21 Jun 2015 10:35:59 +0200 Subject: [PATCH 123/158] Cover more invalid mark procedures Expose multiple error conditions with invalid hostnames and missing servers in order to catch PHP errors and suppress those. --- tests/ClientTest.php | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index f44a2b1a0..e6ca25fd9 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -436,4 +436,60 @@ class ClientTest extends \PHPUnit_Framework_TestCase return $object; } + + /** + * @group udp + */ + public function testWriteUDPPackagesToNoOne() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setHost("127.0.0.1"); + $options->setUsername("nothing"); + $options->setPassword("nothing"); + $options->setPort(64071); //This is a wrong port + + $adapter = new UdpAdapter($options); + $object = new Client($adapter); + + $object->mark("udp.test", ["mark" => "element"]); + } + + /** + * @group udp + */ + public function testReplicateIssue27() + { + $options = new \InfluxDB\Options(); + + // Configure options + $options->setHost('172.16.1.182'); + $options->setPort(4444); + $options->setDatabase('...'); + $options->setUsername('root'); + $options->setPassword('root'); + + $udpAdapter = new \InfluxDB\Adapter\UdpAdapter($options); + $client = new \InfluxDB\Client($udpAdapter); + + $client->mark("udp.test", ["mark" => "element"]); + } + + /** + * @group udp + */ + public function testWriteUDPPackagesToInvalidHostname() + { + $rawOptions = $this->rawOptions; + $options = new Options(); + $options->setHost("www.test-invalid.this-is-not-a-tld"); + $options->setUsername("nothing"); + $options->setPassword("nothing"); + $options->setPort(15984); + + $adapter = new UdpAdapter($options); + $object = new Client($adapter); + + $object->mark("udp.test", ["mark" => "element"]); + } } From 662f4c978aea0eea844c7db96092bf12bcff2b4b Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 21 Jun 2015 10:56:16 +0200 Subject: [PATCH 124/158] Removed duplicated testcase on issue #27 --- tests/ClientTest.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index e6ca25fd9..cd682e617 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -455,26 +455,6 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object->mark("udp.test", ["mark" => "element"]); } - /** - * @group udp - */ - public function testReplicateIssue27() - { - $options = new \InfluxDB\Options(); - - // Configure options - $options->setHost('172.16.1.182'); - $options->setPort(4444); - $options->setDatabase('...'); - $options->setUsername('root'); - $options->setPassword('root'); - - $udpAdapter = new \InfluxDB\Adapter\UdpAdapter($options); - $client = new \InfluxDB\Client($udpAdapter); - - $client->mark("udp.test", ["mark" => "element"]); - } - /** * @group udp */ From 20a64e724bdd73a22ceb2f8b417229e36790811a Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 23 Jun 2015 07:18:41 +0200 Subject: [PATCH 125/158] Test suite completely rewritten Our test suite mixing integration and few unit tests, is difficult to understand and expand with new features. This commit rewrite completely the test suite in order to separate both: integration and unit tests in different suites in a more maintainable and useful way. --- composer.json | 3 +- composer.lock | 92 ++-- phpunit.xml.dist | 19 +- src/Adapter/UdpAdapter.php | 11 +- tests/ClientTest.php | 475 ------------------ tests/bootstrap.php | 18 - .../integration/Adapter/GuzzleAdapterTest.php | 72 +++ tests/integration/ClientTest.php | 166 ++++++ tests/integration/Framework/TestCase.php | 91 ++++ tests/unit/Adapter/GuzzleAdapterTest.php | 180 +++++++ tests/{ => unit}/Adapter/UdpAdapterTest.php | 78 +++ tests/{ => unit}/ClientFactoryTest.php | 0 tests/unit/ClientTest.php | 65 +++ 13 files changed, 710 insertions(+), 560 deletions(-) delete mode 100644 tests/ClientTest.php delete mode 100644 tests/bootstrap.php create mode 100644 tests/integration/Adapter/GuzzleAdapterTest.php create mode 100644 tests/integration/ClientTest.php create mode 100644 tests/integration/Framework/TestCase.php create mode 100644 tests/unit/Adapter/GuzzleAdapterTest.php rename tests/{ => unit}/Adapter/UdpAdapterTest.php (58%) rename tests/{ => unit}/ClientFactoryTest.php (100%) create mode 100644 tests/unit/ClientTest.php diff --git a/composer.json b/composer.json index 7c0fce5de..298b3aaf0 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ }, "autoload-dev": { "psr-4": { - "InfluxDB\\": ["./tests/"] + "InfluxDB\\": ["./tests/unit"], + "InfluxDB\\Integration\\": ["./tests/integration"] } }, "suggest": { diff --git a/composer.lock b/composer.lock index 40b847c1f..882bc4fe7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "61a6988d1b757bb9d3a074d156d73f9d", + "hash": "4a2caee24e54a12ad907d21ddda10e87", "packages": [ { "name": "guzzlehttp/guzzle", @@ -429,16 +429,16 @@ }, { "name": "doctrine/instantiator", - "version": "1.0.4", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { @@ -449,7 +449,7 @@ "ext-pdo": "*", "ext-phar": "*", "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "2.0.*@ALPHA" + "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { @@ -458,8 +458,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Instantiator\\": "src" + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" } }, "notification-url": "https://packagist.org/downloads/", @@ -479,7 +479,7 @@ "constructor", "instantiate" ], - "time": "2014-10-13 12:58:55" + "time": "2015-06-14 21:17:01" }, { "name": "kevinlebrun/colors.php", @@ -685,16 +685,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.1.5", + "version": "2.1.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "be2286cb8c7e1773eded49d9719219e6f74f9e3e" + "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/be2286cb8c7e1773eded49d9719219e6f74f9e3e", - "reference": "be2286cb8c7e1773eded49d9719219e6f74f9e3e", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/631e365cf26bb2c078683e8d9bcf8bc631ac4d44", + "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44", "shasum": "" }, "require": { @@ -743,7 +743,7 @@ "testing", "xunit" ], - "time": "2015-06-09 13:05:42" + "time": "2015-06-19 07:11:55" }, { "name": "phpunit/php-file-iterator", @@ -794,16 +794,16 @@ }, { "name": "phpunit/php-text-template", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "shasum": "" }, "require": { @@ -812,20 +812,17 @@ "type": "library", "autoload": { "classmap": [ - "Text/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -834,20 +831,20 @@ "keywords": [ "template" ], - "time": "2014-01-30 17:20:04" + "time": "2015-06-21 13:50:34" }, { "name": "phpunit/php-timer", - "version": "1.0.5", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d", + "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d", "shasum": "" }, "require": { @@ -856,13 +853,10 @@ "type": "library", "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -878,20 +872,20 @@ "keywords": [ "timer" ], - "time": "2013-08-02 07:42:54" + "time": "2015-06-13 07:35:30" }, { "name": "phpunit/php-token-stream", - "version": "1.4.1", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "eab81d02569310739373308137284e0158424330" + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330", - "reference": "eab81d02569310739373308137284e0158424330", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", + "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", "shasum": "" }, "require": { @@ -927,20 +921,20 @@ "keywords": [ "tokenizer" ], - "time": "2015-04-08 04:46:07" + "time": "2015-06-19 03:43:16" }, { "name": "phpunit/phpunit", - "version": "4.7.3", + "version": "4.7.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "41fea1e84ed84d373f5ac099a1276c4358c90708" + "reference": "f6701ef3faea759acd1910a7751d8d102a7fd5bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/41fea1e84ed84d373f5ac099a1276c4358c90708", - "reference": "41fea1e84ed84d373f5ac099a1276c4358c90708", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f6701ef3faea759acd1910a7751d8d102a7fd5bc", + "reference": "f6701ef3faea759acd1910a7751d8d102a7fd5bc", "shasum": "" }, "require": { @@ -954,7 +948,7 @@ "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0", + "phpunit/php-timer": ">=1.0.6", "phpunit/phpunit-mock-objects": "~2.3", "sebastian/comparator": "~1.1", "sebastian/diff": "~1.2", @@ -999,7 +993,7 @@ "testing", "xunit" ], - "time": "2015-06-11 16:20:25" + "time": "2015-06-21 07:23:36" }, { "name": "phpunit/phpunit-mock-objects", @@ -1440,16 +1434,16 @@ }, { "name": "sebastian/version", - "version": "1.0.5", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", - "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", "shasum": "" }, "type": "library", @@ -1471,7 +1465,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-02-24 06:35:25" + "time": "2015-06-21 13:59:46" }, { "name": "symfony/yaml", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 64303a46a..36a9debbe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,24 +5,15 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" - verbose="false"> + verbose="true"> - tests + tests/integration + + + tests/unit - - - - - - - - - - - - src diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index 2f9930087..b4c17a1e4 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -3,7 +3,7 @@ namespace InfluxDB\Adapter; use DateTime; -final class UdpAdapter extends AdapterAbstract +class UdpAdapter extends AdapterAbstract { public function send(array $message) { @@ -37,7 +37,7 @@ final class UdpAdapter extends AdapterAbstract $tags = array_replace_recursive($tags, $message["tags"]); } - $unixepoch = (int)(microtime(true) * 1e9); + $unixepoch = $this->generateTimeInNanoSeconds(); if (array_key_exists("time", $message)) { $dt = new DateTime($message["time"]); $unixepoch = (int)($dt->format("U") * 1e9); @@ -68,7 +68,12 @@ final class UdpAdapter extends AdapterAbstract return implode("\n", $lines); } - private function toKeyValue(array $elems, $escape=false) + protected function generateTimeInNanoSeconds() + { + return (int)(microtime(true) * 1e9); + } + + protected function toKeyValue(array $elems, $escape=false) { $list = []; foreach ($elems as $key => $value) { diff --git a/tests/ClientTest.php b/tests/ClientTest.php deleted file mode 100644 index cd682e617..000000000 --- a/tests/ClientTest.php +++ /dev/null @@ -1,475 +0,0 @@ -rawOptions = $options; - - $tcpOptions = $options["tcp"]; - - $options = new Options(); - $options->setHost($tcpOptions["host"]); - $options->setPort($tcpOptions["port"]); - $options->setUsername($tcpOptions["username"]); - $options->setPassword($tcpOptions["password"]); - $options->setDatabase($tcpOptions["database"]); - - $this->options = $options; - - $guzzleHttp = new GuzzleHttpClient(); - $adapter = new InfluxHttpAdapter($guzzleHttp, $options); - - $influx = new Client($adapter); - $this->object = $influx; - - $databases = $this->object->getDatabases(); - if (array_key_exists("values", $databases["results"][0]["series"][0])) { - foreach ($databases["results"][0]["series"][0]["values"] as $database) { - $this->object->deleteDatabase($database[0]); - } - } - - $this->object->createDatabase($this->rawOptions["udp"]["database"]); - $this->object->createDatabase($this->rawOptions["tcp"]["database"]); - } - - /** - * @group tcp - */ - public function testGuzzleHttpApiWorksCorrectly() - { - $this->object->mark("tcp.test", ["mark" => "element"]); - - sleep(1); - - $body = $this->object->query("select * from \"tcp.test\""); - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group tcp - * @group proxy - */ - public function testGuzzleHttpApiWorksCorrectlyWithProxies() - { - $this->options->setHost("localhost"); - $this->options->setPort(9000); - $this->options->setPrefix("/influxdb"); - $this->object->mark("tcp.test", ["mark" => "element"]); - - sleep(2); - - $body = $this->object->query("select * from \"tcp.test\""); - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group tcp - */ - public function testGuzzleHttpQueryApiWorksCorrectly() - { - $this->object->mark("tcp.test", ["mark" => "element"]); - - sleep(1); - - $body = $this->object->query("select * from \"tcp.test\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group tcp - */ - public function testGuzzleHttpQueryApiWithMultipleData() - { - $this->object->mark("tcp.test", ["mark" => "element"]); - $this->object->mark("tcp.test", ["mark" => "element2"]); - $this->object->mark("tcp.test", ["mark" => "element3"]); - - sleep(1); - - $body = $this->object->query("select mark from \"tcp.test\"", "s"); - - $this->assertCount(3, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("mark", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals("element", $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group tcp - */ - public function testWriteDirectMessages() - { - $this->object->mark([ - "tags" => [ - "dc" => "eu-west-1", - ], - "points" => [ - [ - "measurement" => "vm-serie", - "fields" => [ - "cpu" => 18.12, - "free" => 712423, - ], - ], - ] - ]); - - sleep(1); - - $body = $this->object->query("select * from \"vm-serie\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group tcp - */ - public function testOverrideDatabaseNameViaMessage() - { - $this->options->setDatabase("a-wrong-database"); - - $this->object->mark([ - "database" => "tcp.test", - "points" => [ - [ - "measurement" => "vm-serie", - "fields" => [ - "cpu" => 18.12, - "free" => 712423, - ], - ], - ] - ]); - - sleep(1); - - $this->options->setDatabase("tcp.test"); - $body = $this->object->query("select * from \"vm-serie\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); - $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); - } - - /** - * @group udp - */ - public function testUdpIpWriteData() - { - $object = $this->createClientWithUdpAdapter(); - - $object->mark("udp.test", ["mark" => "element"]); - $object->mark("udp.test", ["mark" => "element1"]); - $object->mark("udp.test", ["mark" => "element2"]); - $object->mark("udp.test", ["mark" => "element3"]); - - // Wait UDP/IP message arrives - sleep(2); - - $this->options->setDatabase("udp.test"); - $body = $this->object->query("select * from \"udp.test\""); - - $this->assertCount(4, $body["results"][0]["series"][0]["values"]); - } - - /** - * @group udp - */ - public function testSendMultipleMeasurementWithUdpIp() - { - $object = $this->createClientWithUdpAdapter(); - - $object->mark([ - "points" => [ - [ - "measurement" => "mem", - "fields" => [ - "free" => 712423, - ], - ], - [ - "measurement" => "cpu", - "fields" => [ - "cpu" => 18.12, - ], - ], - ] - ]); - - sleep(2); - - $this->options->setDatabase("udp.test"); - $body = $this->object->query("select * from \"cpu\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); - - $body = $this->object->query("select * from \"mem\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("free", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][1]); - } - - /** - * @group udp - */ - public function testWriteDirectMessageWithUdpIp() - { - $object = $this->createClientWithUdpAdapter(); - - $object->mark([ - "points" => [ - [ - "measurement" => "vm-serie", - "fields" => [ - "cpu" => 18.12, - "free" => 712423, - ], - ], - ] - ]); - - sleep(2); - - $this->options->setDatabase("udp.test"); - $body = $this->object->query("select * from \"vm-serie\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); - $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); - } - - /** - * @group udp - * @group date - */ - public function testWriteDirectMessageWillPreserveActualTime() - { - $object = $this->createClientWithUdpAdapter(); - - $object->mark([ - "points" => [ - [ - "measurement" => "vm-serie", - "fields" => [ - "cpu" => 18.12, - "free" => 712423, - ], - ], - ] - ]); - - sleep(2); - - $this->options->setDatabase("udp.test"); - $body = $this->object->query("select * from \"vm-serie\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("time", $body["results"][0]["series"][0]["columns"][0]); - $saved = $body["results"][0]["series"][0]["values"][0][0]; - $this->assertRegExp("/".date("Y-m-d")."/i", $saved); - } - - /** - * @group udp - * @group date - */ - public function testWriteDirectMessageWillPreserveDatetime() - { - $object = $this->createClientWithUdpAdapter(); - - $object->mark([ - "time" => "2009-11-10T23:00:00Z", - "points" => [ - [ - "measurement" => "vm-serie", - "fields" => [ - "cpu" => 18.12, - "free" => 712423, - ], - ], - ] - ]); - - sleep(2); - - $this->options->setDatabase("udp.test"); - $body = $this->object->query("select * from \"vm-serie\""); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("time", $body["results"][0]["series"][0]["columns"][0]); - $this->assertEquals("2009-11-10T23:00:00Z", $body["results"][0]["series"][0]["values"][0][0]); - } - - /** - * @group udp - * @group tags - */ - public function testTagsAreWrittenCorrectly() - { - $object = $this->createClientWithUdpAdapter(); - - $object->mark([ - "tags" => [ - "region" => "eu", - ], - "points" => [ - [ - "measurement" => "vm-serie", - "tags" => [ - "dc" => "eu-west-1", - "one" => "two", - ], - "fields" => [ - "cpu" => 18.12, - "free" => 712423, - ], - ], - [ - "measurement" => "vm-serie", - "tags" => [ - "dc" => "us-east-1", - ], - "fields" => [ - "cpu" => 28.12, - "free" => 412923, - ], - ], - ] - ]); - - sleep(2); - - $this->options->setDatabase("udp.test"); - $body = $this->object->query("select * from \"vm-serie\" where dc='eu-west-1'"); - - $this->assertCount(1, $body["results"][0]["series"][0]["values"]); - $this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]); - $this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]); - $this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][2]); - } - - /** - * Test that we handle socket problems correctly in the UDP - * adapter, and that they don't inturrupt the user's application. - * - * @group udp - */ - public function testReplicateIssue27() - { - $options = new \InfluxDB\Options(); - - // Configure options - $options->setHost('172.16.1.182'); - $options->setPort(4444); - $options->setDatabase('...'); - $options->setUsername('root'); - $options->setPassword('root'); - - $httpAdapter = new \InfluxDB\Adapter\UdpAdapter($options); - - $client = new \InfluxDB\Client($httpAdapter); - $client->mark("udp.test", ["mark" => "element"]); - } - - public function testListActiveDatabses() - { - $databases = $this->object->getDatabases(); - - $this->assertCount(2, $databases["results"][0]["series"][0]["values"]); - } - - public function testCreateANewDatabase() - { - $this->object->createDatabase("walter"); - - sleep(1); - - $databases = $this->object->getDatabases(); - - $this->assertCount(3, $databases["results"][0]["series"][0]["values"]); - - $this->object->deleteDatabase("walter"); - } - - private function createClientWithUdpAdapter() - { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost($rawOptions["udp"]["host"]); - $options->setUsername($rawOptions["udp"]["username"]); - $options->setPassword($rawOptions["udp"]["password"]); - $options->setPort($rawOptions["udp"]["port"]); - $options->setDatabase($rawOptions["udp"]["database"]); - - $adapter = new UdpAdapter($options); - $object = new Client($adapter); - - return $object; - } - - /** - * @group udp - */ - public function testWriteUDPPackagesToNoOne() - { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost("127.0.0.1"); - $options->setUsername("nothing"); - $options->setPassword("nothing"); - $options->setPort(64071); //This is a wrong port - - $adapter = new UdpAdapter($options); - $object = new Client($adapter); - - $object->mark("udp.test", ["mark" => "element"]); - } - - /** - * @group udp - */ - public function testWriteUDPPackagesToInvalidHostname() - { - $rawOptions = $this->rawOptions; - $options = new Options(); - $options->setHost("www.test-invalid.this-is-not-a-tld"); - $options->setUsername("nothing"); - $options->setPassword("nothing"); - $options->setPort(15984); - - $adapter = new UdpAdapter($options); - $object = new Client($adapter); - - $object->mark("udp.test", ["mark" => "element"]); - } -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index 4f2e9ae33..000000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - "host" => getenv('HOST'), - "port" => getenv('TCP_PORT'), - "protocol" => getenv('TCP_PROTOCOL'), - "database" => getenv('TCP_DB'), - "username" => getenv('USERNAME'), - "password" => getenv('PASSWORD'), - ], - "udp" => [ - "host" => getenv('HOST'), - "port" => getenv('UDP_PORT'), - "database" => getenv('UDP_DB'), - "username" => getenv('USERNAME'), - "password" => getenv('PASSWORD'), - ], -]; diff --git a/tests/integration/Adapter/GuzzleAdapterTest.php b/tests/integration/Adapter/GuzzleAdapterTest.php new file mode 100644 index 000000000..eed5132c1 --- /dev/null +++ b/tests/integration/Adapter/GuzzleAdapterTest.php @@ -0,0 +1,72 @@ +getClient()->createDatabase("tcp.test"); + + $options = new Options(); + $options->setPort(8086); + $options->setDatabase("tcp.test"); + + $http = new GuzzleHttpClient(); + $adapter = new GuzzleAdapter($http, $options); + + $adapter->send([ + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + $this->assertSerieExists("tcp.test", "vm-serie"); + $this->assertSerieCount("tcp.test", "vm-serie", 1); + $this->assertValueExistsInSerie("tcp.test", "vm-serie", "cpu", 18.12); + $this->assertValueExistsInSerie("tcp.test", "vm-serie", "free", 712423); + } + + public function testWorksWithProxies() + { + $this->getClient()->createDatabase("proxy.test"); + + $options = new Options(); + $options->setPort(9000); + $options->setDatabase("proxy.test"); + $options->setPrefix("/influxdb"); + + $http = new GuzzleHttpClient(); + $adapter = new GuzzleAdapter($http, $options); + + $adapter->send([ + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + + $this->assertSerieExists("proxy.test", "vm-serie"); + $this->assertSerieCount("proxy.test", "vm-serie", 1); + $this->assertValueExistsInSerie("proxy.test", "vm-serie", "cpu", 18.12); + $this->assertValueExistsInSerie("proxy.test", "vm-serie", "free", 712423); + } +} diff --git a/tests/integration/ClientTest.php b/tests/integration/ClientTest.php new file mode 100644 index 000000000..1b56232e6 --- /dev/null +++ b/tests/integration/ClientTest.php @@ -0,0 +1,166 @@ +getClient()->createDatabase("tcp.test"); + $this->getClient()->createDatabase("udp.test"); + } + + public function testSimpleMarkPublicSignature() + { + $options = new Options(); + $options->setDatabase("tcp.test"); + + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); + $client = new Client($adapter); + + $client->mark("vm", ["mark" => "element"]); + + $this->assertSerieExists("tcp.test", "vm"); + $this->assertSerieCount("tcp.test", "vm", 1); + $this->assertValueExistsInSerie("tcp.test", "vm", "mark", "element"); + } + + public function testDirectMessagesMarkPublicSignature() + { + $options = new Options(); + $options->setDatabase("tcp.test"); + + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); + $client = new Client($adapter); + + $client->mark([ + "database" => "tcp.test", + "retentionPolicy" => "default", + "points" => [ + [ + "measurement" => "tt", + "fields" => [ + "cpu" => 1, + "mem" => 2, + ], + ] + ], + ]); + + $this->assertSerieExists("tcp.test", "tt"); + $this->assertSerieCount("tcp.test", "tt", 1); + $this->assertValueExistsInSerie("tcp.test", "tt", "cpu", 1); + $this->assertValueExistsInSerie("tcp.test", "tt", "mem", 2); + } + + public function testListActiveDatabases() + { + $options = new Options(); + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); + $client = new Client($adapter); + + $databases = $client->getDatabases(); + + $this->assertCount(2, $databases["results"][0]["series"][0]["values"]); + } + + public function testCreateANewDatabase() + { + $options = new Options(); + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); + + $client = new Client($adapter); + + $client->createDatabase("walter"); + + $databases = $client->getDatabases(); + + $this->assertCount(3, $databases["results"][0]["series"][0]["values"]); + } + + public function testDropExistingDatabase() + { + $options = new Options(); + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); + + $client = new Client($adapter); + + $client->createDatabase("walter"); + $this->assertDatabasesCount(3); + + $client->deleteDatabase("walter"); + $this->assertDatabasesCount(2); + } + + /** + * Test that we handle socket problems correctly in the UDP + * adapter, and that they don't inturrupt the user's application. + * + * @group udp + */ + public function testReplicateIssue27() + { + $options = new \InfluxDB\Options(); + + // Configure options + $options->setHost('172.16.1.182'); + $options->setPort(4444); + $options->setDatabase('...'); + $options->setUsername('root'); + $options->setPassword('root'); + + $httpAdapter = new \InfluxDB\Adapter\UdpAdapter($options); + + $client = new \InfluxDB\Client($httpAdapter); + $client->mark("udp.test", ["mark" => "element"]); + } + + /** + * @group udp + */ + public function testWriteUDPPackagesToNoOne() + { + $options = new Options(); + $options->setHost("127.0.0.1"); + $options->setUsername("nothing"); + $options->setPassword("nothing"); + $options->setPort(64071); //This is a wrong port + + $adapter = new UdpAdapter($options); + $object = new Client($adapter); + + $object->mark("udp.test", ["mark" => "element"]); + } + + /** + * @group udp + */ + public function testWriteUDPPackagesToInvalidHostname() + { + $options = new Options(); + $options->setHost("www.test-invalid.this-is-not-a-tld"); + $options->setUsername("nothing"); + $options->setPassword("nothing"); + $options->setPort(15984); + + $adapter = new UdpAdapter($options); + $object = new Client($adapter); + + $object->mark("udp.test", ["mark" => "element"]); + } +} diff --git a/tests/integration/Framework/TestCase.php b/tests/integration/Framework/TestCase.php new file mode 100644 index 000000000..6f6d15107 --- /dev/null +++ b/tests/integration/Framework/TestCase.php @@ -0,0 +1,91 @@ +options = new Options(); + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); + + $client = $this->client = new Client($adapter); + + $this->dropAll(); + } + + public function tearDown() + { + $this->dropAll(); + } + + private function dropAll() + { + $databases = $this->getClient()->getDatabases(); + if (array_key_exists("values", $databases["results"][0]["series"][0])) { + foreach ($databases["results"][0]["series"][0]["values"] as $database) { + $this->getClient()->deleteDatabase($database[0]); + } + } + } + + public function assertValueExistsInSerie($database, $serieName, $column, $value) + { + $this->getOptions()->setDatabase($database); + $body = $this->getClient()->query("select {$column} from \"{$serieName}\""); + + foreach ($body["results"][0]["series"][0]["values"] as $result) { + if ($result[1] == $value) { + return $this->assertTrue(true); + } + } + + return $this->fail("Missing value '{$value}'"); + } + + public function assertSerieCount($database, $serieName, $count) + { + $this->getOptions()->setDatabase($database); + $body = $this->getClient()->query("select * from \"{$serieName}\""); + + $this->assertCount(1, $body["results"][0]["series"][0]["values"]); + } + + public function assertSerieExists($database, $serieName) + { + $this->getOptions()->setDatabase($database); + $body = $this->getClient()->query("show measurements"); + + foreach ($body["results"][0]["series"][0]["values"] as $result) { + if ($result[0] == $serieName) { + return $this->assertTrue(true); + } + } + + return $this->fail("Missing serie with name '{$serieName}' in database '{$database}'"); + } + + public function assertDatabasesCount($count) + { + $databases = $this->client->getDatabases(); + $this->assertCount($count, $databases["results"][0]["series"][0]["values"]); + } + + public function getOptions() + { + return $this->options; + } + + public function getClient() + { + return $this->client; + } +} diff --git a/tests/unit/Adapter/GuzzleAdapterTest.php b/tests/unit/Adapter/GuzzleAdapterTest.php new file mode 100644 index 000000000..3cc77da21 --- /dev/null +++ b/tests/unit/Adapter/GuzzleAdapterTest.php @@ -0,0 +1,180 @@ +getMethod("getHttpSeriesEndpoint"); + $method->setAccessible(true); + + $endpoint = $method->invokeArgs($adapter, []); + $this->assertEquals($final, $endpoint); + } + + public function getWriteEndpoints() + { + return [ + ["http://localhost:9000/write", (new Options())->setHost("localhost")->setPort(9000)], + ["https://localhost:9000/write", (new Options())->setHost("localhost")->setPort(9000)->setProtocol("https")], + ["http://localhost:9000/influxdb/write", (new Options())->setHost("localhost")->setPort(9000)->setPrefix("/influxdb")], + ]; + } + + /** + * @group tcp + * @group proxy + * @dataProvider getQueryEndpoints + */ + public function testQueryEndpointGeneration($final, $options) + { + $guzzleHttp = new GuzzleHttpClient(); + $adapter = new InfluxHttpAdapter($guzzleHttp, $options); + + $reflection = new \ReflectionClass(get_class($adapter)); + $method = $reflection->getMethod("getHttpQueryEndpoint"); + $method->setAccessible(true); + + $endpoint = $method->invokeArgs($adapter, []); + $this->assertEquals($final, $endpoint); + } + + public function getQueryEndpoints() + { + return [ + ["http://localhost:9000/query", (new Options())->setHost("localhost")->setPort(9000)], + ["https://localhost:9000/query", (new Options())->setHost("localhost")->setPort(9000)->setProtocol("https")], + ["http://localhost:9000/influxdb/query", (new Options())->setHost("localhost")->setPort(9000)->setPrefix("/influxdb")], + ]; + } + + public function testMergeWithDefaultOptions() + { + $options = new Options(); + $options->setDatabase("db"); + $httpClient = $this->prophesize("GuzzleHttp\\Client"); + $httpClient->post(Argument::Any(), [ + "auth" => ["root", "root"], + "body" => '{"database":"db","retentionPolicy":"default"}', + ])->shouldBeCalledTimes(1); + + $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); + $adapter->send([]); + } + + public function testAdapterPrepareJsonDataCorrectly() + { + $guzzleHttp = $this->prophesize("GuzzleHttp\Client"); + $guzzleHttp->post("http://localhost:8086/write", [ + "auth" => ["root", "root"], + "body" => '{"database":"db","retentionPolicy":"default","points":[{"measurement":"tcp.test","fields":{"mark":"element"}}]}', + ])->shouldBeCalledTimes(1); + $options = (new Options())->setDatabase("db"); + $adapter = new InfluxHttpAdapter($guzzleHttp->reveal(), $options); + + $adapter->send([ + "points" => [ + [ + "measurement" => "tcp.test", + "fields" => [ + "mark" => "element" + ] + ] + ] + ]); + } + + public function testDefaultOptionOverwrite() + { + $options = new Options(); + $options->setDatabase("db"); + $httpClient = $this->prophesize("GuzzleHttp\\Client"); + $httpClient->post(Argument::Any(), [ + "auth" => ["root", "root"], + "body" => '{"database":"mydb","retentionPolicy":"myPolicy"}', + ])->shouldBeCalledTimes(1); + + $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); + $adapter->send([ + "database" => "mydb", + "retentionPolicy" => "myPolicy" + ]); + } + + public function testEmptyTagsFieldIsRemoved() + { + $options = new Options(); + $options->setDatabase("db"); + $httpClient = $this->prophesize("GuzzleHttp\\Client"); + $httpClient->post(Argument::Any(), [ + "auth" => ["root", "root"], + "body" => '{"database":"mydb","retentionPolicy":"myPolicy"}', + ])->shouldBeCalledTimes(1); + + $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); + $adapter->send([ + "database" => "mydb", + "retentionPolicy" => "myPolicy", + "tags" => [], + ]); + } + + public function testGlobalTagsAreInPlace() + { + $options = new Options(); + $options->setDatabase("db"); + $options->setTags([ + "dc" => "us-west", + ]); + $httpClient = $this->prophesize("GuzzleHttp\\Client"); + $httpClient->post(Argument::Any(), [ + "auth" => ["root", "root"], + "body" => '{"database":"mydb","retentionPolicy":"myPolicy","tags":{"dc":"us-west"}}', + ])->shouldBeCalledTimes(1); + + $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); + $adapter->send([ + "database" => "mydb", + "retentionPolicy" => "myPolicy", + ]); + } + + public function testTagsFieldIsMergedWithGlobalTags() + { + $options = new Options(); + $options->setDatabase("db"); + $options->setTags([ + "dc" => "us-west", + ]); + $httpClient = $this->prophesize("GuzzleHttp\\Client"); + $httpClient->post(Argument::Any(), [ + "auth" => ["root", "root"], + "body" => '{"database":"mydb","retentionPolicy":"myPolicy","tags":{"dc":"us-west","region":"us"}}', + ])->shouldBeCalledTimes(1); + + $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); + $adapter->send([ + "database" => "mydb", + "retentionPolicy" => "myPolicy", + "tags" => ["region" => "us"], + ]); + } +} diff --git a/tests/Adapter/UdpAdapterTest.php b/tests/unit/Adapter/UdpAdapterTest.php similarity index 58% rename from tests/Adapter/UdpAdapterTest.php rename to tests/unit/Adapter/UdpAdapterTest.php index fa5908086..7ff6b42f2 100644 --- a/tests/Adapter/UdpAdapterTest.php +++ b/tests/unit/Adapter/UdpAdapterTest.php @@ -1,7 +1,13 @@ setDatabase("test"); + $adapter = $this->getMockBuilder("InfluxDB\\Adapter\\UdpAdapter") + ->setConstructorArgs([$options]) + ->setMethods(["write", "generateTimeInNanoSeconds"]) + ->getMock(); + + $adapter->expects($this->any()) + ->method("generateTimeInNanoSeconds") + ->will($this->returnValue(1245)); + + $adapter->expects($this->once()) + ->method("write") + ->with("udp.test mark=\"element\" 1245"); + + $adapter->send([ + "points" => [ + [ + "measurement" => "udp.test", + "fields" => [ + "mark" => "element" + ] + ] + ] + ]); + } + + /** + * @group udp + */ + public function testSendMultipleMeasurementWithUdpIp() + { + $options = (new Options())->setDatabase("test"); + $adapter = $this->getMockBuilder("InfluxDB\\Adapter\\UdpAdapter") + ->setConstructorArgs([$options]) + ->setMethods(["write", "generateTimeInNanoSeconds"]) + ->getMock(); + + $adapter->expects($this->any()) + ->method("generateTimeInNanoSeconds") + ->will($this->onConsecutiveCalls(1245, 1246)); + + $adapter->expects($this->once()) + ->method("write") + ->with(<<send([ + "points" => [ + [ + "measurement" => "mem", + "fields" => [ + "free" => 712423, + ], + ], + [ + "measurement" => "cpu", + "fields" => [ + "cpu" => 18.12, + ], + ], + ] + ]); + } } diff --git a/tests/ClientFactoryTest.php b/tests/unit/ClientFactoryTest.php similarity index 100% rename from tests/ClientFactoryTest.php rename to tests/unit/ClientFactoryTest.php diff --git a/tests/unit/ClientTest.php b/tests/unit/ClientTest.php new file mode 100644 index 000000000..4cc843af1 --- /dev/null +++ b/tests/unit/ClientTest.php @@ -0,0 +1,65 @@ +prophesize("InfluxDB\\Adapter\\WritableInterface"); + $mock->send([ + "points" => [ + [ + "measurement" => "tcp.test", + "fields" => [ + "mark" => "element" + ] + ] + ] + ])->shouldBeCalledTimes(1); + + $object = new Client($mock->reveal()); + $object->mark("tcp.test", ["mark" => "element"]); + } + + public function testWriteDirectMessages() + { + $mock = $this->prophesize("InfluxDB\\Adapter\\WritableInterface"); + $mock->send([ + "tags" => [ + "dc" => "eu-west-1", + ], + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ] + ] + ] + ])->shouldBeCalledTimes(1); + $object = new Client($mock->reveal()); + + $object->mark([ + "tags" => [ + "dc" => "eu-west-1", + ], + "points" => [ + [ + "measurement" => "vm-serie", + "fields" => [ + "cpu" => 18.12, + "free" => 712423, + ], + ], + ] + ]); + } +} From 03ade4c6005dbc7348af422bae9dc1b57ac8ad89 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 23 Jun 2015 19:28:14 +0200 Subject: [PATCH 126/158] Added UDP/IP integration tests --- tests/integration/Adapter/UdpAdapterTest.php | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/integration/Adapter/UdpAdapterTest.php diff --git a/tests/integration/Adapter/UdpAdapterTest.php b/tests/integration/Adapter/UdpAdapterTest.php new file mode 100644 index 000000000..f04c629ad --- /dev/null +++ b/tests/integration/Adapter/UdpAdapterTest.php @@ -0,0 +1,53 @@ +setPort(4444); + $adapter = new UdpAdapter($options); + + $this->getClient()->createDatabase("udp.test"); + + $adapter->write("cpu value=12.33 " . (int)(microtime(true)*1e9)); + + sleep(2); + + $this->assertSerieExists("udp.test", "cpu"); + $this->assertSerieCount("udp.test", "cpu", 1); + $this->assertValueExistsInSerie("udp.test", "cpu", "value", 12.33); + } + + public function testWriteSimplePointsUsingSendMethod() + { + $options = (new Options()) + ->setPort(4444); + $adapter = new UdpAdapter($options); + + $this->getClient()->createDatabase("udp.test"); + + $adapter->send([ + "retentionPolicy" => "default", + "points" => [ + [ + "measurement" => "mem", + "fields" => [ + "value" => 1233, + ], + ], + ], + ]); + + sleep(2); + + $this->assertSerieExists("udp.test", "mem"); + $this->assertSerieCount("udp.test", "mem", 1); + $this->assertValueExistsInSerie("udp.test", "mem", "value", 1233); + } +} From d9dbd9ba931dd2e207e163ae2f8c41eeabc65413 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 23 Jun 2015 19:35:04 +0200 Subject: [PATCH 127/158] Change contributing guidelines --- CONTRIBUTING.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7af948a1a..778ffc64c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,4 @@ We are always thrilled to receive pull requests. We do our best to process them quickly. If your pull request is not accepted on the first try, don't get discouraged! -We follows the *vincent driessen's branching model* -[http://nvie.com/posts/a-successful-git-branching-model/](http://nvie.com/posts/a-successful-git-branching-model/) - +Just branch on master and prepare your PR. From 113f1167c3476932ee5927be73e194a7732e7867 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 23 Jun 2015 19:39:49 +0200 Subject: [PATCH 128/158] Removed develop badge --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b38953782..4b3ac940c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # InfluxDB PHP SDK - * Master: [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) - * Develop: [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=develop)](https://travis-ci.org/corley/influxdb-php-sdk) +[![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) Send metrics to InfluxDB and query for any data. From 13a419f4f561fd67f67dcd901aca9682bd5656c2 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 23 Jun 2015 20:45:31 +0200 Subject: [PATCH 129/158] Fixes useless client helper complexity --- src/Client.php | 9 --------- tests/unit/ClientTest.php | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Client.php b/src/Client.php index 97b296f4b..121d39891 100644 --- a/src/Client.php +++ b/src/Client.php @@ -52,25 +52,16 @@ class Client public function getDatabases() { - if (!($this->getAdapter() instanceOf QueryableInterface)) { - throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); - } return $this->getAdapter()->query("show databases"); } public function createDatabase($name) { - if (!($this->getAdapter() instanceOf QueryableInterface)) { - throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); - } return $this->getAdapter()->query("create database \"{$name}\""); } public function deleteDatabase($name) { - if (!($this->getAdapter() instanceOf QueryableInterface)) { - throw new \BadMethodCallException("You can query the database only if the adapter supports it!"); - } return $this->getAdapter()->query("drop database \"{$name}\""); } } diff --git a/tests/unit/ClientTest.php b/tests/unit/ClientTest.php index 4cc843af1..da6586ec5 100644 --- a/tests/unit/ClientTest.php +++ b/tests/unit/ClientTest.php @@ -62,4 +62,22 @@ class ClientTest extends \PHPUnit_Framework_TestCase ] ]); } + + /** + * @expectedException BadMethodCallException + */ + public function testNeedWritableInterfaceDuringMark() + { + $client = new Client(new \stdClass()); + $client->mark("OK", []); + } + + /** + * @expectedException BadMethodCallException + */ + public function testNeedQueryableInterfaceDuringQuery() + { + $client = new Client(new \stdClass()); + $client->query("OK", []); + } } From b02a52e2f76361e17518bf0b3c7cf2e97518a274 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 23 Jun 2015 20:49:44 +0200 Subject: [PATCH 130/158] Cover missing class on factory method --- tests/unit/ClientFactoryTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unit/ClientFactoryTest.php b/tests/unit/ClientFactoryTest.php index a7f0e44f1..91031eb5d 100644 --- a/tests/unit/ClientFactoryTest.php +++ b/tests/unit/ClientFactoryTest.php @@ -114,4 +114,16 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase ["InfluxDB\\Adapter\\GuzzleAdapter"], ]; } + + /** + * @expectedException InvalidArgumentException + */ + public function testInvalidProviderThrowsException() + { + $client = ClientFactory::create([ + "adapter" => [ + "name" => "InvalidClass", + ], + ]); + } } From a364f8ad0c0a55e7707b65d94f4cf53c0af3545c Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 23 Jun 2015 20:59:21 +0200 Subject: [PATCH 131/158] Cover tag merge for UdpAdapter --- tests/unit/Adapter/UdpAdapterTest.php | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/unit/Adapter/UdpAdapterTest.php b/tests/unit/Adapter/UdpAdapterTest.php index 7ff6b42f2..3a536f3e3 100644 --- a/tests/unit/Adapter/UdpAdapterTest.php +++ b/tests/unit/Adapter/UdpAdapterTest.php @@ -169,4 +169,43 @@ EOF ] ]); } + + /** + * @group udp + */ + public function testMergeGlobalTags() + { + $options = (new Options()) + ->setDatabase("test") + ->setTags(["dc" => "eu-west"]); + $adapter = $this->getMockBuilder("InfluxDB\\Adapter\\UdpAdapter") + ->setConstructorArgs([$options]) + ->setMethods(["write", "generateTimeInNanoSeconds"]) + ->getMock(); + + $adapter->expects($this->any()) + ->method("generateTimeInNanoSeconds") + ->will($this->returnValue(1245)); + + $adapter->expects($this->once()) + ->method("write") + ->with(<<send([ + "tags" => [ + "region" => "eu-west-1", + ], + "points" => [ + [ + "measurement" => "mem", + "fields" => [ + "free" => 712423, + ], + ], + ] + ]); + } } From 44551a58e9ca74d69bf755b6fc930df9de83fa33 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 07:58:41 +0200 Subject: [PATCH 132/158] Test tags are full merged --- tests/unit/Adapter/UdpAdapterTest.php | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/unit/Adapter/UdpAdapterTest.php b/tests/unit/Adapter/UdpAdapterTest.php index 3a536f3e3..d9125f1b7 100644 --- a/tests/unit/Adapter/UdpAdapterTest.php +++ b/tests/unit/Adapter/UdpAdapterTest.php @@ -208,4 +208,46 @@ EOF ] ]); } + + /** + * @group udp + */ + public function testMergeFullTagsPositions() + { + $options = (new Options()) + ->setDatabase("test") + ->setTags(["dc" => "eu-west"]); + $adapter = $this->getMockBuilder("InfluxDB\\Adapter\\UdpAdapter") + ->setConstructorArgs([$options]) + ->setMethods(["write", "generateTimeInNanoSeconds"]) + ->getMock(); + + $adapter->expects($this->any()) + ->method("generateTimeInNanoSeconds") + ->will($this->returnValue(1245)); + + $adapter->expects($this->once()) + ->method("write") + ->with(<<send([ + "tags" => [ + "region" => "eu-west-1", + ], + "points" => [ + [ + "measurement" => "mem", + "tags" => [ + "location" => "ireland", + ], + "fields" => [ + "free" => 712423, + ], + ], + ] + ]); + } } From c7c3690e0bfaaeb81d7065bbfb5d43492f3d1fe8 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 07:58:54 +0200 Subject: [PATCH 133/158] Cover more factory method invalid arguments --- tests/unit/ClientFactoryTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/unit/ClientFactoryTest.php b/tests/unit/ClientFactoryTest.php index 91031eb5d..8143b00bf 100644 --- a/tests/unit/ClientFactoryTest.php +++ b/tests/unit/ClientFactoryTest.php @@ -117,13 +117,19 @@ class ClientFactoryTest extends \PHPUnit_Framework_TestCase /** * @expectedException InvalidArgumentException + * @dataProvider getInvalidClasses */ - public function testInvalidProviderThrowsException() + public function testInvalidProviderThrowsException($class) { $client = ClientFactory::create([ "adapter" => [ - "name" => "InvalidClass", + "name" => $class, ], ]); } + + public function getInvalidClasses() + { + return [["InvalidClass"],["stdClass"]]; + } } From f3a273f6d9670c0418743f0d3d8592b8bda9fad8 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 07:59:28 +0200 Subject: [PATCH 134/158] Added codeclimate dev-dependency --- composer.json | 1 + composer.lock | 528 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 527 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 298b3aaf0..a9f2435c8 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "zendframework/zend-servicemanager": "~2" }, "require-dev": { + "codeclimate/php-test-reporter": "dev-master", "phpunit/phpunit": "4.*", "athletic/athletic": "~0.1", "ext-sockets": "*" diff --git a/composer.lock b/composer.lock index 882bc4fe7..16711fc9f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "4a2caee24e54a12ad907d21ddda10e87", + "hash": "ea197cdcb24cfde2b668ae1750adbfc0", "packages": [ { "name": "guzzlehttp/guzzle", @@ -427,6 +427,64 @@ ], "time": "2014-06-03 18:32:22" }, + { + "name": "codeclimate/php-test-reporter", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/codeclimate/php-test-reporter.git", + "reference": "418ae782307841ac50fe26daa4cfe04520b0de9c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/418ae782307841ac50fe26daa4cfe04520b0de9c", + "reference": "418ae782307841ac50fe26daa4cfe04520b0de9c", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3", + "satooshi/php-coveralls": "0.6.*", + "symfony/console": ">=2.0" + }, + "require-dev": { + "ext-xdebug": "*", + "phpunit/phpunit": "3.7.*@stable" + }, + "bin": [ + "composer/bin/test-reporter" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "CodeClimate\\Component": "src/", + "CodeClimate\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Code Climate", + "email": "hello@codeclimate.com", + "homepage": "https://codeclimate.com" + } + ], + "description": "PHP client for reporting test coverage to Code Climate", + "homepage": "https://github.com/codeclimate/php-test-reporter", + "keywords": [ + "codeclimate", + "coverage" + ], + "time": "2015-04-18 14:43:54" + }, { "name": "doctrine/instantiator", "version": "1.0.5", @@ -481,6 +539,101 @@ ], "time": "2015-06-14 21:17:01" }, + { + "name": "guzzle/guzzle", + "version": "v3.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-03-18 18:23:50" + }, { "name": "kevinlebrun/colors.php", "version": "0.2.0", @@ -1096,6 +1249,112 @@ ], "time": "2014-07-24 07:10:08" }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "satooshi/php-coveralls", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": ">=3.0", + "php": ">=5.3", + "psr/log": "1.0.0", + "symfony/config": ">=2.0", + "symfony/console": ">=2.0", + "symfony/stopwatch": ">=2.2", + "symfony/yaml": ">=2.0" + }, + "require-dev": { + "apigen/apigen": "2.8.*@stable", + "pdepend/pdepend": "dev-master", + "phpmd/phpmd": "dev-master", + "phpunit/php-invoker": ">=1.1.0,<1.2.0", + "phpunit/phpunit": "3.7.*@stable", + "sebastian/finder-facade": "dev-master", + "sebastian/phpcpd": "1.4.*@stable", + "squizlabs/php_codesniffer": "1.4.*@stable", + "theseer/fdomdocument": "dev-master" + }, + "bin": [ + "composer/bin/coveralls" + ], + "type": "library", + "autoload": { + "psr-0": { + "Contrib\\Component": "src/", + "Contrib\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2013-05-04 08:07:33" + }, { "name": "sebastian/comparator", "version": "1.1.1", @@ -1467,6 +1726,269 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2015-06-21 13:59:46" }, + { + "name": "symfony/config", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/58ded81f1f582a87c528ef3dae9a859f78b5f374", + "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/filesystem": "~2.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "time": "2015-06-11 14:06:56" + }, + { + "name": "symfony/console", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "564398bc1f33faf92fc2ec86859983d30eb81806" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806", + "reference": "564398bc1f33faf92fc2ec86859983d30eb81806", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.1" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2015-06-10 15:30:22" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9", + "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5", + "symfony/dependency-injection": "~2.6", + "symfony/expression-language": "~2.6", + "symfony/phpunit-bridge": "~2.7", + "symfony/stopwatch": "~2.3" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/filesystem", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2015-06-08 09:37:21" + }, + { + "name": "symfony/stopwatch", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2015-06-04 20:11:48" + }, { "name": "symfony/yaml", "version": "v2.7.1", @@ -1559,7 +2081,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "codeclimate/php-test-reporter": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From 6c9646e0850068f084b04024acba32d804966c5e Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 08:06:40 +0200 Subject: [PATCH 135/158] Tests against php7 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 72b9027c3..51c32bf6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: php php: - 5.5 - 5.6 + - 7 before_install: - sudo apt-get update From b9bc6958de1af8eacd7b819a10b241fb4f2df18f Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 08:23:01 +0200 Subject: [PATCH 136/158] Added codeclimate --- .codeclimate.yml | 6 ++++++ .travis.yml | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .codeclimate.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 000000000..f1770ee51 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,6 @@ +languages: + PHP: true +exclude_paths: + - tests/* + - benchmarks/* + - scripts/* diff --git a/.travis.yml b/.travis.yml index 51c32bf6f..737c18237 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,10 @@ before_script: - composer install --prefer-source script: - - vendor/bin/phpunit + - vendor/bin/phpunit --coverage-clover build/logs/clover.xml + +after_script: + - CODECLIMATE_REPO_TOKEN=$CODECLIMATE_REPO_TOKEN vendor/bin/test-reporter notifications: slack: From 1465f446764b7542597f886a6549ff95c1380a18 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 08:24:16 +0200 Subject: [PATCH 137/158] Allow PHP7 failures until a stable version --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 737c18237..df0cade7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,10 @@ script: after_script: - CODECLIMATE_REPO_TOKEN=$CODECLIMATE_REPO_TOKEN vendor/bin/test-reporter +matrix: + allow_failures: + - php: 7 + notifications: slack: secure: UN4V33CfLzEcb+5/LWcfcbwROZobbUawgFSiM3TzagBC+7w0DH2rK8DczxkUBs5rNAaYBj+DkxmmF9tiDb0BLB7Jezlq0vmrNBOhregLodOG44/bFwg58YOwTGxt/Iak38A+8VskGj0sSybNq4TB1/K0040wXS5bA+M/9NqyQeo= From a33083479d2b832a8fde26b4113b445d0c12418a Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 08:26:31 +0200 Subject: [PATCH 138/158] Added codeclimate badges --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4b3ac940c..af9d2a1d7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # InfluxDB PHP SDK [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) +[![Code Climate](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/gpa.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk) +[![Test Coverage](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/coverage.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk/coverage) Send metrics to InfluxDB and query for any data. From ffe45967c1839dd95a4757975a1e6872a9d92383 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 10:01:20 +0200 Subject: [PATCH 139/158] Fixes code duplication The HTTP endpoint generation is effectively duplicated --- src/Adapter/GuzzleAdapter.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php index 35a3a6db4..cb5b9f4be 100644 --- a/src/Adapter/GuzzleAdapter.php +++ b/src/Adapter/GuzzleAdapter.php @@ -53,23 +53,23 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface protected function getHttpSeriesEndpoint() { - return sprintf( - "%s://%s:%d%s/write", - $this->getOptions()->getProtocol(), - $this->getOptions()->getHost(), - $this->getOptions()->getPort(), - $this->getOptions()->getPrefix() - ); + return $this->getHttpEndpoint("write"); } - protected function getHttpQueryEndpoint($name = false) + protected function getHttpQueryEndpoint() + { + return $this->getHttpEndpoint("query"); + } + + private function getHttpEndpoint($operation) { $url = sprintf( - "%s://%s:%d%s/query", + "%s://%s:%d%s/%s", $this->getOptions()->getProtocol(), $this->getOptions()->getHost(), $this->getOptions()->getPort(), - $this->getOptions()->getPrefix() + $this->getOptions()->getPrefix(), + $operation ); return $url; From 6c4bd35844aabbff474546abf3bff7ee8bbad2f9 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 10:23:36 +0200 Subject: [PATCH 140/158] Added scrutinizer inspection badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af9d2a1d7..3314295d3 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) [![Code Climate](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/gpa.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk) [![Test Coverage](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/coverage.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk/coverage) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/?branch=master) Send metrics to InfluxDB and query for any data. @@ -242,7 +243,7 @@ In that way the SDK use that policy instead of `default` policy. ## Proxies and InfluxDB -If you proxy your InfluxDB typically you have a prefix in your endpoints. +If you proxy your InfluxDB typically you have a prefix in your endpoints. ``` $option->setHost("proxy.influxdb.tld"); From 39a87feb5aebecfc05d5cfec4b932ca71943730c Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 24 Jun 2015 11:36:34 +0200 Subject: [PATCH 141/158] I want all possible badges! --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3314295d3..e8f640f1a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ [![Code Climate](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/gpa.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk) [![Test Coverage](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/coverage.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk/coverage) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/?branch=master) +[![Latest Stable Version](https://poser.pugx.org/corley/influxdb-sdk/v/stable)](https://packagist.org/packages/corley/influxdb-sdk) +[![License](https://poser.pugx.org/corley/influxdb-sdk/license)](https://packagist.org/packages/corley/influxdb-sdk) Send metrics to InfluxDB and query for any data. From fa61a3cd7aa38fa9a09bdb69e6f999cae5659233 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 24 Jun 2015 20:44:36 +0000 Subject: [PATCH 142/158] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- src/Adapter/UdpAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index b4c17a1e4..50f420512 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -73,7 +73,7 @@ class UdpAdapter extends AdapterAbstract return (int)(microtime(true) * 1e9); } - protected function toKeyValue(array $elems, $escape=false) + protected function toKeyValue(array $elems, $escape = false) { $list = []; foreach ($elems as $key => $value) { From 932cd992ff2a9fa9c2eb7489c67a947d905e2c14 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 25 Jun 2015 09:56:58 +0200 Subject: [PATCH 143/158] Optimized list to string conversion The inline protocol converts key values to strings --- README.md | 6 +- .../Benchmarks/InfluxDB/AdapterEvent.php | 2 + .../InfluxDB/MessageToInlineProtocolEvent.php | 28 ++------ composer.json | 3 +- composer.lock | 2 +- src/Adapter/UdpAdapter.php | 68 +++---------------- src/Adapter/helpers.php | 52 ++++++++++++++ src/inline_protocol_functions.php | 15 ++++ tests/integration/Adapter/UdpAdapterTest.php | 2 + tests/unit/Adapter/HelpersTest.php | 23 +++++++ tests/unit/Adapter/UdpAdapterTest.php | 51 +++++++++----- 11 files changed, 148 insertions(+), 104 deletions(-) create mode 100644 src/Adapter/helpers.php create mode 100644 src/inline_protocol_functions.php create mode 100644 tests/unit/Adapter/HelpersTest.php diff --git a/README.md b/README.md index e8f640f1a..50460f30e 100644 --- a/README.md +++ b/README.md @@ -284,9 +284,9 @@ The impact of message to inline protocol conversion is: Corley\Benchmarks\InfluxDB\MessageToInlineProtocolEvent Method Name Iterations Average Time Ops/second ---------------------------------------------------- ------------ -------------- ------------- - convertMessageToInlineProtocolWithNoTags : [10,000 ] [0.0000237422466] [42,119.01324] - convertMessageToInlineProtocolWithGlobalTags : [10,000 ] [0.0000306700468] [32,605.10185] - convertMessageToInlineProtocolWithDifferentTagLevels: [10,000 ] [0.0000343942404] [29,074.63543] + convertMessageToInlineProtocolWithNoTags : [10,000 ] [0.0000343696594] [29,095.42942] + convertMessageToInlineProtocolWithGlobalTags : [10,000 ] [0.0000437165260] [22,874.64469] + convertMessageToInlineProtocolWithDifferentTagLevels: [10,000 ] [0.0000493728638] [20,254.04086] ``` ## FAQ diff --git a/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php b/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php index e52604941..d3d37f6e5 100644 --- a/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php +++ b/benchmarks/Benchmarks/InfluxDB/AdapterEvent.php @@ -23,6 +23,8 @@ class AdapterEvent extends AthleticEvent $options->setDatabase("tcp.test"); $client = new Client(new GuzzleAdapter(new HttpClient(), $options)); + $client->createDatabase("tcp.test"); + $client->createDatabase("udp.test"); $this->httpClient = $client; diff --git a/benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php b/benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php index 4bfce6ee9..964fdc34e 100644 --- a/benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php +++ b/benchmarks/Benchmarks/InfluxDB/MessageToInlineProtocolEvent.php @@ -2,31 +2,15 @@ namespace Corley\Benchmarks\InfluxDB; use Athletic\AthleticEvent; -use InfluxDB\Adapter\UdpAdapter; -use InfluxDB\Options; class MessageToInlineProtocolEvent extends AthleticEvent { - private $method; - private $object; - - public function setUp() - { - $object = new UdpAdapter(new Options()); - $reflection = new \ReflectionClass(get_class($object)); - $method = $reflection->getMethod("serialize"); - $method->setAccessible(true); - - $this->method = $method; - $this->object = $object; - } - /** * @iterations 10000 */ public function convertMessageToInlineProtocolWithNoTags() { - $this->method->invokeArgs($this->object, [ + \InfluxDB\Adapter\message_to_inline_protocol( [ "points" => [ [ @@ -38,7 +22,7 @@ class MessageToInlineProtocolEvent extends AthleticEvent ], ] ] - ]); + ); } /** @@ -46,7 +30,7 @@ class MessageToInlineProtocolEvent extends AthleticEvent */ public function convertMessageToInlineProtocolWithGlobalTags() { - $this->method->invokeArgs($this->object, [ + \InfluxDB\Adapter\message_to_inline_protocol( [ "tags" => [ "dc" => "eu-west-1", @@ -61,7 +45,7 @@ class MessageToInlineProtocolEvent extends AthleticEvent ], ] ] - ]); + ); } /** @@ -69,7 +53,7 @@ class MessageToInlineProtocolEvent extends AthleticEvent */ public function convertMessageToInlineProtocolWithDifferentTagLevels() { - $this->method->invokeArgs($this->object, [ + \InfluxDB\Adapter\message_to_inline_protocol( [ "tags" => [ "dc" => "eu-west-1", @@ -87,6 +71,6 @@ class MessageToInlineProtocolEvent extends AthleticEvent ], ] ] - ]); + ); } } diff --git a/composer.json b/composer.json index a9f2435c8..dd69664b3 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "psr-4": { "InfluxDB\\": ["./src/"], "Corley\\": ["./benchmarks/"] - } + }, + "files": ["src/Adapter/helpers.php"] }, "autoload-dev": { "psr-4": { diff --git a/composer.lock b/composer.lock index 16711fc9f..61cce25d3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ea197cdcb24cfde2b668ae1750adbfc0", + "hash": "6378134d2378fee11d7741fb4343074d", "packages": [ { "name": "guzzlehttp/guzzle", diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index 50f420512..ac9a08ba6 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -8,7 +8,12 @@ class UdpAdapter extends AdapterAbstract public function send(array $message) { $message = array_replace_recursive($this->getMessageDefaults(), $message); - $message = $this->serialize($message); + + if (array_key_exists("tags", $message)) { + $message["tags"] = array_replace_recursive($this->getOptions()->getTags(), $message["tags"]); + } + + $message = message_to_inline_protocol($message); $this->write($message); } @@ -17,8 +22,8 @@ class UdpAdapter extends AdapterAbstract { // Create a handler in order to handle the 'Host is down' message set_error_handler(function() { - // Suppress the error, this is the UDP adapter and if we can't send - // it then we shouldn't inturrupt their application. + // Suppress the error, this is the UDP adapter and if we can't send + // it then we shouldn't inturrupt their application. }); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); @@ -28,61 +33,4 @@ class UdpAdapter extends AdapterAbstract // Remove our error handler. restore_error_handler(); } - - private function serialize(array $message) - { - $tags = $this->getOptions()->getTags(); - - if (array_key_exists("tags", $message)) { - $tags = array_replace_recursive($tags, $message["tags"]); - } - - $unixepoch = $this->generateTimeInNanoSeconds(); - if (array_key_exists("time", $message)) { - $dt = new DateTime($message["time"]); - $unixepoch = (int)($dt->format("U") * 1e9); - } - - $lines = []; - foreach ($message["points"] as $point) { - if (array_key_exists("tags", $point)) { - $tags = array_replace_recursive($tags, $point["tags"]); - } - - if (!$tags) { - $lines[] = trim( - sprintf( - "%s %s %d", - $point["measurement"], $this->toKeyValue($point["fields"], true), $unixepoch - ) - ); - } else { - $lines[] = trim( - sprintf( - "%s,%s %s %d", - $point["measurement"], $this->toKeyValue($tags), $this->toKeyValue($point["fields"], true), $unixepoch - ) - ); - } - } - return implode("\n", $lines); - } - - protected function generateTimeInNanoSeconds() - { - return (int)(microtime(true) * 1e9); - } - - protected function toKeyValue(array $elems, $escape = false) - { - $list = []; - foreach ($elems as $key => $value) { - if ($escape && is_string($value)) { - $value = "\"{$value}\""; - } - $list[] = sprintf("%s=%s", $key, $value); - } - - return implode(",", $list); - } } diff --git a/src/Adapter/helpers.php b/src/Adapter/helpers.php new file mode 100644 index 000000000..fcdfe2318 --- /dev/null +++ b/src/Adapter/helpers.php @@ -0,0 +1,52 @@ +format("U") * 1e9); + } + + $lines = []; + foreach ($message["points"] as $point) { + $tags = array_key_exists("tags", $message) ? $message["tags"] : []; + if (array_key_exists("tags", $point)) { + $tags = array_replace_recursive($tags, $point["tags"]); + } + + if (!$tags) { + $lines[] = trim( + sprintf( + "%s %s %d", + $point["measurement"], list_to_string($point["fields"], true), $unixepoch + ) + ); + } else { + $lines[] = trim( + sprintf( + "%s,%s %s %d", + $point["measurement"], list_to_string($tags), list_to_string($point["fields"], true), $unixepoch + ) + ); + } + } + + return implode("\n", $lines); +} + +function list_to_string(array $elements, $escape = false) +{ + array_walk($elements, function(&$value, $key) use ($escape) { + if ($escape && is_string($value)) { + $value = "\"{$value}\""; + } + + $value = "{$key}={$value}"; + }); + + return implode(",", $elements); +} diff --git a/src/inline_protocol_functions.php b/src/inline_protocol_functions.php new file mode 100644 index 000000000..5fffa2fb2 --- /dev/null +++ b/src/inline_protocol_functions.php @@ -0,0 +1,15 @@ + "mem", "fields" => [ "value" => 1233, + "with_string" => "this is a string", ], ], ], @@ -49,5 +50,6 @@ class UdpAdapterTest extends InfluxDBTestCase $this->assertSerieExists("udp.test", "mem"); $this->assertSerieCount("udp.test", "mem", 1); $this->assertValueExistsInSerie("udp.test", "mem", "value", 1233); + $this->assertValueExistsInSerie("udp.test", "mem", "with_string", "this is a string"); } } diff --git a/tests/unit/Adapter/HelpersTest.php b/tests/unit/Adapter/HelpersTest.php new file mode 100644 index 000000000..cc3776413 --- /dev/null +++ b/tests/unit/Adapter/HelpersTest.php @@ -0,0 +1,23 @@ +assertEquals($result, list_to_string($message, $escape)); + } + + public function getElements() + { + return [ + [["one" => "two"], "one=two", false], + [["one" => "two"], "one=\"two\"", true], + [["one" => "two", "three" => "four"], "one=two,three=four", false], + [["one" => "two", "three" => "four"], "one=\"two\",three=\"four\"", true], + ]; + } +} diff --git a/tests/unit/Adapter/UdpAdapterTest.php b/tests/unit/Adapter/UdpAdapterTest.php index d9125f1b7..e9e3ce4f6 100644 --- a/tests/unit/Adapter/UdpAdapterTest.php +++ b/tests/unit/Adapter/UdpAdapterTest.php @@ -17,13 +17,15 @@ class UdpAdapterTest extends \PHPUnit_Framework_TestCase public function testRewriteMessages($input, $response) { $object = new UdpAdapter(new Options()); - $reflection = new \ReflectionClass(get_class($object)); - $method = $reflection->getMethod("serialize"); - $method->setAccessible(true); + $object = $this->getMockBuilder("InfluxDB\Adapter\UdpAdapter") + ->setConstructorArgs([new Options()]) + ->setMethods(["write"]) + ->getMock(); + $object->expects($this->once()) + ->method("write") + ->with($response); - $message = $method->invokeArgs($object, [$input]); - - $this->assertEquals($response, $message); + $object->send($input); } public function getMessages() @@ -43,6 +45,21 @@ class UdpAdapterTest extends \PHPUnit_Framework_TestCase ], "cpu value=1 1257894000000000000" ], + [ + [ + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "cpu", + "fields" => [ + "value" => 1, + "string" => "escape", + ], + ], + ], + ], + "cpu value=1,string=\"escape\" 1257894000000000000" + ], [ [ "tags" => [ @@ -115,7 +132,7 @@ EOF $adapter->expects($this->once()) ->method("write") - ->with("udp.test mark=\"element\" 1245"); + ->with($this->matchesRegularExpression("/udp.test mark=\"element\" \d+/i")); $adapter->send([ "points" => [ @@ -146,11 +163,11 @@ EOF $adapter->expects($this->once()) ->method("write") - ->with(<<with($this->matchesRegularExpression(<<send([ "points" => [ @@ -189,10 +206,10 @@ EOF $adapter->expects($this->once()) ->method("write") - ->with(<<with($this->matchesRegularExpression(<<send([ "tags" => [ @@ -228,10 +245,10 @@ EOF $adapter->expects($this->once()) ->method("write") - ->with(<<with($this->matchesRegularExpression(<<send([ "tags" => [ From 4517e5c31c65219eb14df50f5b713704f79cc401 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 27 Jun 2015 14:20:46 +0200 Subject: [PATCH 144/158] Cover merge global tags also when are missing --- tests/unit/Adapter/UdpAdapterTest.php | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/unit/Adapter/UdpAdapterTest.php b/tests/unit/Adapter/UdpAdapterTest.php index e9e3ce4f6..68271bac4 100644 --- a/tests/unit/Adapter/UdpAdapterTest.php +++ b/tests/unit/Adapter/UdpAdapterTest.php @@ -187,6 +187,35 @@ EOF ]); } + /** + * @group udp + */ + public function testFillWithGlobalTags() + { + $options = (new Options()) + ->setDatabase("test") + ->setTags(["dc" => "eu-west"]); + $adapter = $this->getMockBuilder("InfluxDB\\Adapter\\UdpAdapter") + ->setConstructorArgs([$options]) + ->setMethods(["write"]) + ->getMock(); + + $adapter->expects($this->once()) + ->method("write") + ->with($this->matchesRegularExpression("/mem,dc=eu-west free=712423 \d+/i")); + + $adapter->send([ + "points" => [ + [ + "measurement" => "mem", + "fields" => [ + "free" => 712423, + ], + ], + ] + ]); + } + /** * @group udp */ From 4924c0b116f21d3cc5655a47e3eef8ded2f95ce8 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 27 Jun 2015 14:28:56 +0200 Subject: [PATCH 145/158] Removed old helper file --- src/inline_protocol_functions.php | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/inline_protocol_functions.php diff --git a/src/inline_protocol_functions.php b/src/inline_protocol_functions.php deleted file mode 100644 index 5fffa2fb2..000000000 --- a/src/inline_protocol_functions.php +++ /dev/null @@ -1,15 +0,0 @@ - Date: Sat, 27 Jun 2015 14:34:35 +0200 Subject: [PATCH 146/158] Moved to scrutinizer --- .codeclimate.yml | 6 ------ .scrutinizer.yml | 3 +++ .travis.yml | 5 +++-- README.md | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 .codeclimate.yml create mode 100644 .scrutinizer.yml diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index f1770ee51..000000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,6 +0,0 @@ -languages: - PHP: true -exclude_paths: - - tests/* - - benchmarks/* - - scripts/* diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 000000000..963a7af45 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,3 @@ +tools: + external_code_coverage: + timeout: 600 diff --git a/.travis.yml b/.travis.yml index df0cade7d..c04149d95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,10 +24,11 @@ before_script: - composer install --prefer-source script: - - vendor/bin/phpunit --coverage-clover build/logs/clover.xml + - vendor/bin/phpunit --coverage-clover clover.xml after_script: - - CODECLIMATE_REPO_TOKEN=$CODECLIMATE_REPO_TOKEN vendor/bin/test-reporter + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover clover.xml matrix: allow_failures: diff --git a/README.md b/README.md index 50460f30e..7cf80eeef 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # InfluxDB PHP SDK [![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) -[![Code Climate](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/gpa.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk) -[![Test Coverage](https://codeclimate.com/github/corley/influxdb-php-sdk/badges/coverage.svg)](https://codeclimate.com/github/corley/influxdb-php-sdk/coverage) +[![Code Coverage](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/?branch=master) [![Latest Stable Version](https://poser.pugx.org/corley/influxdb-sdk/v/stable)](https://packagist.org/packages/corley/influxdb-sdk) [![License](https://poser.pugx.org/corley/influxdb-sdk/license)](https://packagist.org/packages/corley/influxdb-sdk) From 3fd559fab2fa85c90918bd9deedd37c75ce530a8 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 27 Jun 2015 14:45:26 +0200 Subject: [PATCH 147/158] Removed useless condition We can only prepare two adapters --- src/ClientFactory.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ClientFactory.php b/src/ClientFactory.php index 33789ec8a..690dbbd32 100644 --- a/src/ClientFactory.php +++ b/src/ClientFactory.php @@ -24,19 +24,15 @@ abstract class ClientFactory ], "options" => [], ]; - $options = array_replace_recursive($defaultOptions, $options); - $adapterName = $options["adapter"]["name"]; - if (!class_exists($adapterName)) { - throw new \InvalidArgumentException("Missing class: {$adapterName}"); - } $adapterOptions = new Options(); $hydrator = new ClassMethods(); $hydrator->hydrate($options["options"], $adapterOptions); $adapter = null; + $adapterName = $options["adapter"]["name"]; switch ($adapterName) { case 'InfluxDB\\Adapter\\UdpAdapter': $adapter = new $adapterName($adapterOptions); From 0e656fc39a0dc5bbea50e9b639b3eb1e5ca75960 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 28 Jun 2015 09:31:15 +0200 Subject: [PATCH 148/158] Added circle-ci file --- README.md | 2 +- circle.yml | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 circle.yml diff --git a/README.md b/README.md index 7cf80eeef..1a4bd553b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # InfluxDB PHP SDK -[![Build Status](https://travis-ci.org/corley/influxdb-php-sdk.svg?branch=master)](https://travis-ci.org/corley/influxdb-php-sdk) +[![Circle CI](https://circleci.com/gh/corley/influxdb-php-sdk/tree/master.svg?style=svg)](https://circleci.com/gh/corley/influxdb-php-sdk/tree/master) [![Code Coverage](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/corley/influxdb-php-sdk/?branch=master) [![Latest Stable Version](https://poser.pugx.org/corley/influxdb-sdk/v/stable)](https://packagist.org/packages/corley/influxdb-sdk) diff --git a/circle.yml b/circle.yml new file mode 100644 index 000000000..3c3d17db0 --- /dev/null +++ b/circle.yml @@ -0,0 +1,23 @@ +machine: + timezone: + Europe/Rome + php: + version: 5.6.5 + +dependencies: + pre: + - sudo apt-get update + - sudo apt-get install nginx + - wget https://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb + - sudo useradd influxdb + - sudo dpkg -i influxdb_latest_amd64.deb + - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf + - sudo /opt/influxdb/influxd -config /etc/opt/influxdb/influxdb.conf: {background: true} + - sudo cp scripts/nginx_proxy.conf /etc/nginx/conf.d/proxy.conf + - sudo service nginx restart +test: + override: + - vendor/bin/phpunit --coverage-clover clover.xml + post: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover clover.xml From fbbddbfeacf23c9384362ae5d2fc91fe0547b3b1 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sun, 28 Jun 2015 10:07:00 +0200 Subject: [PATCH 149/158] Moved to circle-ci --- .travis.yml | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c04149d95..000000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: php - -php: - - 5.5 - - 5.6 - - 7 - -before_install: - - sudo apt-get update - - sudo apt-get install libcurl4-openssl-dev libjson0-dev - - wget https://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb - - sudo useradd influxdb - - sudo dpkg -i influxdb_latest_amd64.deb - - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - - travis_retry sudo service influxdb restart - - sudo service influxdb status - - sudo apt-get update - - sudo apt-get install -y nginx - - sudo cp scripts/nginx_proxy.conf /etc/nginx/conf.d/proxy.conf - - travis_retry sudo service nginx restart - -before_script: - - composer selfupdate - - composer install --prefer-source - -script: - - vendor/bin/phpunit --coverage-clover clover.xml - -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover clover.xml - -matrix: - allow_failures: - - php: 7 - -notifications: - slack: - secure: UN4V33CfLzEcb+5/LWcfcbwROZobbUawgFSiM3TzagBC+7w0DH2rK8DczxkUBs5rNAaYBj+DkxmmF9tiDb0BLB7Jezlq0vmrNBOhregLodOG44/bFwg58YOwTGxt/Iak38A+8VskGj0sSybNq4TB1/K0040wXS5bA+M/9NqyQeo= From 84c3a52899f880fcfd5f1fb27320dec4c9abf8c3 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Wed, 1 Jul 2015 09:16:06 +0200 Subject: [PATCH 150/158] suggest dbal --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index dd69664b3..c09aca9ec 100644 --- a/composer.json +++ b/composer.json @@ -45,6 +45,7 @@ } }, "suggest": { + "corley/dbal-influxdb": "This library help you to build query", "fabpot/pimple": "Allows to prepare the client dependencies in order to require an initialized instance", "zendframework/zend-servicemanager": "Use a service locator in order to prepare a valid instance", "symfony/dependency-injection": "Prepare a valid instance via the symfony DiC" From f556fc3f8639187d1415979126948cdaa13a476c Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 1 Jul 2015 16:10:48 +0200 Subject: [PATCH 151/158] Force xdebug extension --- circle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/circle.yml b/circle.yml index 3c3d17db0..f40298150 100644 --- a/circle.yml +++ b/circle.yml @@ -15,6 +15,8 @@ dependencies: - sudo /opt/influxdb/influxd -config /etc/opt/influxdb/influxdb.conf: {background: true} - sudo cp scripts/nginx_proxy.conf /etc/nginx/conf.d/proxy.conf - sudo service nginx restart + - sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini + test: override: - vendor/bin/phpunit --coverage-clover clover.xml From 0cd433e3c6c6ce9e3270746931f19c0544f6c8e2 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 3 Jul 2015 16:19:17 +0200 Subject: [PATCH 152/158] Added query builder docs --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index 1a4bd553b..09662befe 100644 --- a/README.md +++ b/README.md @@ -288,6 +288,43 @@ Corley\Benchmarks\InfluxDB\MessageToInlineProtocolEvent convertMessageToInlineProtocolWithDifferentTagLevels: [10,000 ] [0.0000493728638] [20,254.04086] ``` +### Query Builder + +Interested in a Query Builder? + +https://github.com/corley/dbal-influxdb + +Thanks to Doctrine DBAL (Abstract Layer) you can use the query builder + +``` +$qb = $conn->createQueryBuilder(); + +$qb->select("*") + ->from("cpu_load_short") + ->where("time = ?") + ->setParameter(0, 1434055562000000000); + +$data = $qb->execute(); +foreach ($data->fetchAll() as $element) { + // Use your element +} +``` + +```php +$config = new \Doctrine\DBAL\Configuration(); +//.. +$connectionParams = array( + 'dbname' => 'mydb', + 'user' => 'root', + 'password' => 'root', + 'host' => 'localhost', + 'port' => 8086, + "driverClass" => "Corley\\DBAL\\Driver\\InfluxDB", +); +$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); +``` + + ## FAQ ### Add sockets support to your PHP From aa6ba1e154bf42481a41b09cba7b216ad7be3bec Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Tue, 28 Jul 2015 18:16:33 +0200 Subject: [PATCH 153/158] Moved to inline protocol. As json messages are deprecated we have moved to inline protocol. --- src/Adapter/GuzzleAdapter.php | 6 +- src/Adapter/helpers.php | 4 ++ tests/unit/Adapter/GuzzleAdapterTest.php | 71 +++++++++++++++++++----- 3 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php index cb5b9f4be..70950ac9e 100644 --- a/src/Adapter/GuzzleAdapter.php +++ b/src/Adapter/GuzzleAdapter.php @@ -25,7 +25,11 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface $httpMessage = [ "auth" => [$this->getOptions()->getUsername(), $this->getOptions()->getPassword()], - "body" => json_encode($message) + 'query' => [ + "db" => $message["database"], + "retentionPolicy" => $message["retentionPolicy"], + ], + "body" => message_to_inline_protocol($message) ]; $endpoint = $this->getHttpSeriesEndpoint(); diff --git a/src/Adapter/helpers.php b/src/Adapter/helpers.php index fcdfe2318..b67649cdf 100644 --- a/src/Adapter/helpers.php +++ b/src/Adapter/helpers.php @@ -5,6 +5,10 @@ use DateTime; function message_to_inline_protocol(array $message) { + if (!array_key_exists("points", $message)) { + return; + } + $unixepoch = (int)(microtime(true) * 1e9); if (array_key_exists("time", $message)) { $dt = new DateTime($message["time"]); diff --git a/tests/unit/Adapter/GuzzleAdapterTest.php b/tests/unit/Adapter/GuzzleAdapterTest.php index 3cc77da21..57aaf5b72 100644 --- a/tests/unit/Adapter/GuzzleAdapterTest.php +++ b/tests/unit/Adapter/GuzzleAdapterTest.php @@ -73,7 +73,11 @@ class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase $httpClient = $this->prophesize("GuzzleHttp\\Client"); $httpClient->post(Argument::Any(), [ "auth" => ["root", "root"], - "body" => '{"database":"db","retentionPolicy":"default"}', + "query" => [ + "db" => "db", + "retentionPolicy" => "default", + ], + "body" => null, ])->shouldBeCalledTimes(1); $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); @@ -85,12 +89,17 @@ class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase $guzzleHttp = $this->prophesize("GuzzleHttp\Client"); $guzzleHttp->post("http://localhost:8086/write", [ "auth" => ["root", "root"], - "body" => '{"database":"db","retentionPolicy":"default","points":[{"measurement":"tcp.test","fields":{"mark":"element"}}]}', + "query" => [ + "db" => "db", + "retentionPolicy" => "default", + ], + "body" => 'tcp.test mark="element" 1257894000000000000', ])->shouldBeCalledTimes(1); $options = (new Options())->setDatabase("db"); $adapter = new InfluxHttpAdapter($guzzleHttp->reveal(), $options); $adapter->send([ + "time" => "2009-11-10T23:00:00Z", "points" => [ [ "measurement" => "tcp.test", @@ -109,7 +118,11 @@ class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase $httpClient = $this->prophesize("GuzzleHttp\\Client"); $httpClient->post(Argument::Any(), [ "auth" => ["root", "root"], - "body" => '{"database":"mydb","retentionPolicy":"myPolicy"}', + "query" => [ + "db" => "mydb", + "retentionPolicy" => "myPolicy", + ], + "body" => null, ])->shouldBeCalledTimes(1); $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); @@ -126,14 +139,24 @@ class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase $httpClient = $this->prophesize("GuzzleHttp\\Client"); $httpClient->post(Argument::Any(), [ "auth" => ["root", "root"], - "body" => '{"database":"mydb","retentionPolicy":"myPolicy"}', + "query" => [ + "db" => "db", + "retentionPolicy" => "default", + ], + "body" => 'tcp.test mark="element" 1257894000000000000', ])->shouldBeCalledTimes(1); $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); $adapter->send([ - "database" => "mydb", - "retentionPolicy" => "myPolicy", - "tags" => [], + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "tcp.test", + "fields" => [ + "mark" => "element" + ] + ] + ] ]); } @@ -147,13 +170,24 @@ class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase $httpClient = $this->prophesize("GuzzleHttp\\Client"); $httpClient->post(Argument::Any(), [ "auth" => ["root", "root"], - "body" => '{"database":"mydb","retentionPolicy":"myPolicy","tags":{"dc":"us-west"}}', + "query" => [ + "db" => "db", + "retentionPolicy" => "default", + ], + "body" => 'tcp.test,dc=us-west mark="element" 1257894000000000000', ])->shouldBeCalledTimes(1); $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); $adapter->send([ - "database" => "mydb", - "retentionPolicy" => "myPolicy", + "time" => "2009-11-10T23:00:00Z", + "points" => [ + [ + "measurement" => "tcp.test", + "fields" => [ + "mark" => "element" + ] + ] + ] ]); } @@ -167,14 +201,25 @@ class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase $httpClient = $this->prophesize("GuzzleHttp\\Client"); $httpClient->post(Argument::Any(), [ "auth" => ["root", "root"], - "body" => '{"database":"mydb","retentionPolicy":"myPolicy","tags":{"dc":"us-west","region":"us"}}', + "query" => [ + "db" => "db", + "retentionPolicy" => "default", + ], + "body" => 'tcp.test,dc=us-west,region=us mark="element" 1257894000000000000', ])->shouldBeCalledTimes(1); $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options); $adapter->send([ - "database" => "mydb", - "retentionPolicy" => "myPolicy", + "time" => "2009-11-10T23:00:00Z", "tags" => ["region" => "us"], + "points" => [ + [ + "measurement" => "tcp.test", + "fields" => [ + "mark" => "element" + ] + ] + ] ]); } } From 361703cb2500e671f70de94d8dcd4cead89fd21f Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 29 Jul 2015 13:45:08 +0200 Subject: [PATCH 154/158] Updated dependencies --- composer.lock | 229 ++++++++++++++++++++++++++++---------------------- 1 file changed, 129 insertions(+), 100 deletions(-) diff --git a/composer.lock b/composer.lock index 61cce25d3..d13e560af 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,35 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6378134d2378fee11d7741fb4343074d", + "hash": "dcf9aae79158a5a60803e1563891a0fd", "packages": [ + { + "name": "container-interop/container-interop", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/container-interop/container-interop.git", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e", + "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Interop\\Container\\": "src/Interop/Container/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", + "time": "2014-12-30 15:22:37" + }, { "name": "guzzlehttp/guzzle", "version": "5.3.0", @@ -167,16 +194,16 @@ }, { "name": "react/promise", - "version": "v2.2.0", + "version": "v2.2.1", "source": { "type": "git", "url": "https://github.com/reactphp/promise.git", - "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef" + "reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef", - "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef", + "url": "https://api.github.com/repos/reactphp/promise/zipball/3b6fca09c7d56321057fa8867c8dbe1abf648627", + "reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627", "shasum": "" }, "require": { @@ -203,11 +230,11 @@ "authors": [ { "name": "Jan Sorgalla", - "email": "jsorgalla@googlemail.com" + "email": "jsorgalla@gmail.com" } ], "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "time": "2014-12-30 13:32:42" + "time": "2015-07-03 13:48:55" }, { "name": "zendframework/zend-filter", @@ -269,20 +296,21 @@ }, { "name": "zendframework/zend-servicemanager", - "version": "2.5.1", + "version": "2.6.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-servicemanager.git", - "reference": "3b22c403e351d92526c642cba0bd810bc22e1c56" + "reference": "1dc33f23bd0a7f4d8ba743b915fae523d356027a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/3b22c403e351d92526c642cba0bd810bc22e1c56", - "reference": "3b22c403e351d92526c642cba0bd810bc22e1c56", + "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/1dc33f23bd0a7f4d8ba743b915fae523d356027a", + "reference": "1dc33f23bd0a7f4d8ba743b915fae523d356027a", "shasum": "" }, "require": { - "php": ">=5.3.23" + "container-interop/container-interop": "~1.0", + "php": ">=5.5" }, "require-dev": { "fabpot/php-cs-fixer": "1.7.*", @@ -297,8 +325,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" + "dev-master": "2.6-dev", + "dev-develop": "2.7-dev" } }, "autoload": { @@ -315,24 +343,24 @@ "servicemanager", "zf2" ], - "time": "2015-06-03 15:32:02" + "time": "2015-07-23 21:49:08" }, { "name": "zendframework/zend-stdlib", - "version": "2.5.1", + "version": "2.6.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae" + "reference": "a35758803fc9051ec1aff43989e679b6b451b1b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cc8e90a60dd5d44b9730b77d07b97550091da1ae", - "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae", + "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/a35758803fc9051ec1aff43989e679b6b451b1b4", + "reference": "a35758803fc9051ec1aff43989e679b6b451b1b4", "shasum": "" }, "require": { - "php": ">=5.3.23" + "php": ">=5.5" }, "require-dev": { "fabpot/php-cs-fixer": "1.7.*", @@ -353,8 +381,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" + "dev-master": "2.6-dev", + "dev-develop": "2.7-dev" } }, "autoload": { @@ -371,7 +399,7 @@ "stdlib", "zf2" ], - "time": "2015-06-03 15:32:03" + "time": "2015-07-21 17:08:05" } ], "packages-dev": [ @@ -838,16 +866,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.1.6", + "version": "2.1.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44" + "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/631e365cf26bb2c078683e8d9bcf8bc631ac4d44", - "reference": "631e365cf26bb2c078683e8d9bcf8bc631ac4d44", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5bd48b86cd282da411bb80baac1398ce3fefac41", + "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41", "shasum": "" }, "require": { @@ -896,20 +924,20 @@ "testing", "xunit" ], - "time": "2015-06-19 07:11:55" + "time": "2015-07-26 12:54:47" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", - "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", "shasum": "" }, "require": { @@ -943,7 +971,7 @@ "filesystem", "iterator" ], - "time": "2015-04-02 05:19:05" + "time": "2015-06-21 13:08:43" }, { "name": "phpunit/php-text-template", @@ -988,16 +1016,16 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.6", + "version": "1.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d" + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/83fe1bdc5d47658b727595c14da140da92b3d66d", - "reference": "83fe1bdc5d47658b727595c14da140da92b3d66d", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", "shasum": "" }, "require": { @@ -1025,7 +1053,7 @@ "keywords": [ "timer" ], - "time": "2015-06-13 07:35:30" + "time": "2015-06-21 08:01:12" }, { "name": "phpunit/php-token-stream", @@ -1078,16 +1106,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.7.5", + "version": "4.7.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f6701ef3faea759acd1910a7751d8d102a7fd5bc" + "reference": "9b97f9d807b862c2de2a36e86690000801c85724" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f6701ef3faea759acd1910a7751d8d102a7fd5bc", - "reference": "f6701ef3faea759acd1910a7751d8d102a7fd5bc", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b97f9d807b862c2de2a36e86690000801c85724", + "reference": "9b97f9d807b862c2de2a36e86690000801c85724", "shasum": "" }, "require": { @@ -1146,26 +1174,27 @@ "testing", "xunit" ], - "time": "2015-06-21 07:23:36" + "time": "2015-07-13 11:28:34" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.4", + "version": "2.3.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35" + "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/92408bb1968a81b3217a6fdf6c1a198da83caa35", - "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/18dfbcb81d05e2296c0bcddd4db96cade75e6f42", + "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42", "shasum": "" }, "require": { "doctrine/instantiator": "~1.0,>=1.0.2", "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2" + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" }, "require-dev": { "phpunit/phpunit": "~4.4" @@ -1201,7 +1230,7 @@ "mock", "xunit" ], - "time": "2015-06-11 15:55:48" + "time": "2015-07-10 06:54:24" }, { "name": "pimple/pimple", @@ -1357,16 +1386,16 @@ }, { "name": "sebastian/comparator", - "version": "1.1.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", - "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", "shasum": "" }, "require": { @@ -1380,7 +1409,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -1417,7 +1446,7 @@ "compare", "equality" ], - "time": "2015-01-29 16:28:08" + "time": "2015-07-26 15:48:44" }, { "name": "sebastian/diff", @@ -1473,16 +1502,16 @@ }, { "name": "sebastian/environment", - "version": "1.2.2", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", - "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", + "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", "shasum": "" }, "require": { @@ -1519,20 +1548,20 @@ "environment", "hhvm" ], - "time": "2015-01-01 10:01:08" + "time": "2015-07-26 06:42:57" }, { "name": "sebastian/exporter", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "84839970d05254c73cde183a721c7af13aede943" + "reference": "7ae5513327cb536431847bcc0c10edba2701064e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", - "reference": "84839970d05254c73cde183a721c7af13aede943", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", + "reference": "7ae5513327cb536431847bcc0c10edba2701064e", "shasum": "" }, "require": { @@ -1585,7 +1614,7 @@ "export", "exporter" ], - "time": "2015-01-27 07:23:06" + "time": "2015-06-21 07:55:53" }, { "name": "sebastian/global-state", @@ -1640,16 +1669,16 @@ }, { "name": "sebastian/recursion-context", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", - "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", + "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", "shasum": "" }, "require": { @@ -1689,7 +1718,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-01-24 09:48:32" + "time": "2015-06-21 08:04:50" }, { "name": "sebastian/version", @@ -1728,16 +1757,16 @@ }, { "name": "symfony/config", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374" + "reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/58ded81f1f582a87c528ef3dae9a859f78b5f374", - "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374", + "url": "https://api.github.com/repos/symfony/Config/zipball/6c905bbed1e728226de656e4c07d620dfe9e80d9", + "reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9", "shasum": "" }, "require": { @@ -1774,20 +1803,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2015-06-11 14:06:56" + "time": "2015-07-09 16:07:40" }, { "name": "symfony/console", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "564398bc1f33faf92fc2ec86859983d30eb81806" + "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806", - "reference": "564398bc1f33faf92fc2ec86859983d30eb81806", + "url": "https://api.github.com/repos/symfony/Console/zipball/8cf484449130cabfd98dcb4694ca9945802a21ed", + "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed", "shasum": "" }, "require": { @@ -1831,20 +1860,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-06-10 15:30:22" + "time": "2015-07-09 16:07:40" }, { "name": "symfony/event-dispatcher", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9" + "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9", - "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", + "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", "shasum": "" }, "require": { @@ -1889,20 +1918,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2015-06-08 09:37:21" + "time": "2015-06-18 19:21:56" }, { "name": "symfony/filesystem", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" + "reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", - "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/2d7b2ddaf3f548f4292df49a99d19c853d43f0b8", + "reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8", "shasum": "" }, "require": { @@ -1938,20 +1967,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2015-06-08 09:37:21" + "time": "2015-07-09 16:07:40" }, { "name": "symfony/stopwatch", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Stopwatch.git", - "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b" + "reference": "b07a866719bbac5294c67773340f97b871733310" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", - "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b07a866719bbac5294c67773340f97b871733310", + "reference": "b07a866719bbac5294c67773340f97b871733310", "shasum": "" }, "require": { @@ -1987,20 +2016,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2015-06-04 20:11:48" + "time": "2015-07-01 18:23:16" }, { "name": "symfony/yaml", - "version": "v2.7.1", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" + "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", - "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/4bfbe0ed3909bfddd75b70c094391ec1f142f860", + "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860", "shasum": "" }, "require": { @@ -2036,7 +2065,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-06-10 15:30:22" + "time": "2015-07-01 11:25:50" }, { "name": "zeptech/annotations", From 745ff3a5ebe111472ac666028e9938ba49ad5f72 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Wed, 29 Jul 2015 16:44:42 +0200 Subject: [PATCH 155/158] Supports Guzzle6 * Removed `json` method in favor of `getBody` that is supported by all guzzle versions * Removed composer.lock (useless for libraries) --- .gitignore | 1 + composer.json | 2 +- composer.lock | 2124 --------------------------------- src/Adapter/GuzzleAdapter.php | 2 +- 4 files changed, 3 insertions(+), 2126 deletions(-) delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 54527ba06..b7f1a2785 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor tags +composer.lock diff --git a/composer.json b/composer.json index c09aca9ec..6abce12da 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Send your app metrics to InfluxDB", "require": { "php": ">=5.4", - "guzzlehttp/guzzle": "~4|~5", + "guzzlehttp/guzzle": "~4|~5|~6", "zendframework/zend-stdlib": "~2", "zendframework/zend-filter": "~2", "zendframework/zend-servicemanager": "~2" diff --git a/composer.lock b/composer.lock deleted file mode 100644 index d13e560af..000000000 --- a/composer.lock +++ /dev/null @@ -1,2124 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "dcf9aae79158a5a60803e1563891a0fd", - "packages": [ - { - "name": "container-interop/container-interop", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/container-interop/container-interop.git", - "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e", - "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Interop\\Container\\": "src/Interop/Container/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", - "time": "2014-12-30 15:22:37" - }, - { - "name": "guzzlehttp/guzzle", - "version": "5.3.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "f3c8c22471cb55475105c14769644a49c3262b93" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93", - "reference": "f3c8c22471cb55475105c14769644a49c3262b93", - "shasum": "" - }, - "require": { - "guzzlehttp/ringphp": "^1.1", - "php": ">=5.4.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0", - "psr/log": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2015-05-20 03:47:55" - }, - { - "name": "guzzlehttp/ringphp", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/RingPHP.git", - "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", - "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", - "shasum": "" - }, - "require": { - "guzzlehttp/streams": "~3.0", - "php": ">=5.4.0", - "react/promise": "~2.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Ring\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", - "time": "2015-05-20 03:37:09" - }, - { - "name": "guzzlehttp/streams", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/streams.git", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Stream\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple abstraction over streams of data", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "Guzzle", - "stream" - ], - "time": "2014-10-12 19:18:40" - }, - { - "name": "react/promise", - "version": "v2.2.1", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/3b6fca09c7d56321057fa8867c8dbe1abf648627", - "reference": "3b6fca09c7d56321057fa8867c8dbe1abf648627", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "time": "2015-07-03 13:48:55" - }, - { - "name": "zendframework/zend-filter", - "version": "2.5.1", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-filter.git", - "reference": "93e6990a198e6cdd811064083acac4693f4b29ae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/93e6990a198e6cdd811064083acac4693f4b29ae", - "reference": "93e6990a198e6cdd811064083acac4693f4b29ae", - "shasum": "" - }, - "require": { - "php": ">=5.3.23", - "zendframework/zend-stdlib": "~2.5" - }, - "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0", - "zendframework/zend-config": "~2.5", - "zendframework/zend-crypt": "~2.5", - "zendframework/zend-i18n": "~2.5", - "zendframework/zend-loader": "~2.5", - "zendframework/zend-servicemanager": "~2.5", - "zendframework/zend-uri": "~2.5" - }, - "suggest": { - "zendframework/zend-crypt": "Zend\\Crypt component", - "zendframework/zend-i18n": "Zend\\I18n component", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component", - "zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Filter\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "provides a set of commonly needed data filters", - "homepage": "https://github.com/zendframework/zend-filter", - "keywords": [ - "filter", - "zf2" - ], - "time": "2015-06-03 15:32:01" - }, - { - "name": "zendframework/zend-servicemanager", - "version": "2.6.0", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-servicemanager.git", - "reference": "1dc33f23bd0a7f4d8ba743b915fae523d356027a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/1dc33f23bd0a7f4d8ba743b915fae523d356027a", - "reference": "1dc33f23bd0a7f4d8ba743b915fae523d356027a", - "shasum": "" - }, - "require": { - "container-interop/container-interop": "~1.0", - "php": ">=5.5" - }, - "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0", - "zendframework/zend-di": "~2.5", - "zendframework/zend-mvc": "~2.5" - }, - "suggest": { - "ocramius/proxy-manager": "ProxyManager 0.5.* to handle lazy initialization of services", - "zendframework/zend-di": "Zend\\Di component" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev", - "dev-develop": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\ServiceManager\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "homepage": "https://github.com/zendframework/zend-servicemanager", - "keywords": [ - "servicemanager", - "zf2" - ], - "time": "2015-07-23 21:49:08" - }, - { - "name": "zendframework/zend-stdlib", - "version": "2.6.0", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "a35758803fc9051ec1aff43989e679b6b451b1b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/a35758803fc9051ec1aff43989e679b6b451b1b4", - "reference": "a35758803fc9051ec1aff43989e679b6b451b1b4", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0", - "zendframework/zend-config": "~2.5", - "zendframework/zend-eventmanager": "~2.5", - "zendframework/zend-filter": "~2.5", - "zendframework/zend-inputfilter": "~2.5", - "zendframework/zend-serializer": "~2.5", - "zendframework/zend-servicemanager": "~2.5" - }, - "suggest": { - "zendframework/zend-eventmanager": "To support aggregate hydrator usage", - "zendframework/zend-filter": "To support naming strategy hydrator usage", - "zendframework/zend-serializer": "Zend\\Serializer component", - "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev", - "dev-develop": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Stdlib\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "homepage": "https://github.com/zendframework/zend-stdlib", - "keywords": [ - "stdlib", - "zf2" - ], - "time": "2015-07-21 17:08:05" - } - ], - "packages-dev": [ - { - "name": "athletic/athletic", - "version": "v0.1.8", - "source": { - "type": "git", - "url": "https://github.com/polyfractal/athletic.git", - "reference": "51fe4b6e5298dd8af187825a4e57745898e37f0e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/polyfractal/athletic/zipball/51fe4b6e5298dd8af187825a4e57745898e37f0e", - "reference": "51fe4b6e5298dd8af187825a4e57745898e37f0e", - "shasum": "" - }, - "require": { - "nategood/commando": "0.2.1", - "php": ">=5.3.9", - "pimple/pimple": ">=1.0,<3.0", - "zeptech/annotations": "1.1.*" - }, - "require-dev": { - "mikey179/vfsstream": "1.2.*", - "mockery/mockery": "0.8.*", - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "0.6.*" - }, - "bin": [ - "bin/athletic" - ], - "type": "library", - "autoload": { - "psr-0": { - "Athletic": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Zachary Tong" - } - ], - "description": "PHP Benchmarking Framework", - "keywords": [ - "benchmark", - "benchmarking", - "profiling" - ], - "time": "2014-06-03 18:32:22" - }, - { - "name": "codeclimate/php-test-reporter", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/codeclimate/php-test-reporter.git", - "reference": "418ae782307841ac50fe26daa4cfe04520b0de9c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/418ae782307841ac50fe26daa4cfe04520b0de9c", - "reference": "418ae782307841ac50fe26daa4cfe04520b0de9c", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3", - "satooshi/php-coveralls": "0.6.*", - "symfony/console": ">=2.0" - }, - "require-dev": { - "ext-xdebug": "*", - "phpunit/phpunit": "3.7.*@stable" - }, - "bin": [ - "composer/bin/test-reporter" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.1.x-dev" - } - }, - "autoload": { - "psr-0": { - "CodeClimate\\Component": "src/", - "CodeClimate\\Bundle": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Code Climate", - "email": "hello@codeclimate.com", - "homepage": "https://codeclimate.com" - } - ], - "description": "PHP client for reporting test coverage to Code Climate", - "homepage": "https://github.com/codeclimate/php-test-reporter", - "keywords": [ - "codeclimate", - "coverage" - ], - "time": "2015-04-18 14:43:54" - }, - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14 21:17:01" - }, - { - "name": "guzzle/guzzle", - "version": "v3.9.3", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle3.git", - "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", - "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1" - }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", - "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", - "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-error-response": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" - }, - "require-dev": { - "doctrine/cache": "~1.3", - "monolog/monolog": "~1.0", - "phpunit/phpunit": "3.7.*", - "psr/log": "~1.0", - "symfony/class-loader": "~2.1", - "zendframework/zend-cache": "2.*,<2.3", - "zendframework/zend-log": "2.*,<2.3" - }, - "suggest": { - "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.9-dev" - } - }, - "autoload": { - "psr-0": { - "Guzzle": "src/", - "Guzzle\\Tests": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" - } - ], - "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2015-03-18 18:23:50" - }, - { - "name": "kevinlebrun/colors.php", - "version": "0.2.0", - "source": { - "type": "git", - "url": "https://github.com/kevinlebrun/colors.php.git", - "reference": "b13d23b9365ece519abc0eaa77cd3061c5810d30" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kevinlebrun/colors.php/zipball/b13d23b9365ece519abc0eaa77cd3061c5810d30", - "reference": "b13d23b9365ece519abc0eaa77cd3061c5810d30", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Colors": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kevin Le Brun", - "email": "lebrun.k@gmail.com", - "homepage": "http://kevinlebrun.fr", - "role": "developer" - } - ], - "description": "Colors for PHP CLI scripts", - "homepage": "https://github.com/kevinlebrun/colors.php", - "keywords": [ - "cli", - "color", - "colors", - "console", - "shell" - ], - "time": "2012-03-25 18:18:10" - }, - { - "name": "nategood/commando", - "version": "0.2.1", - "source": { - "type": "git", - "url": "https://github.com/nategood/commando.git", - "reference": "b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nategood/commando/zipball/b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1", - "reference": "b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1", - "shasum": "" - }, - "require": { - "kevinlebrun/colors.php": "0.2.*", - "php": ">=5.3" - }, - "type": "library", - "autoload": { - "psr-0": { - "Commando": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nate Good", - "email": "me@nategood.com", - "homepage": "http://nategood.com" - } - ], - "description": "PHP CLI Commando Style", - "homepage": "http://github.com/nategood/commando", - "keywords": [ - "automation", - "cli", - "command", - "command line", - "command line interface", - "scripting" - ], - "time": "2012-10-07 15:35:37" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2015-02-03 12:10:50" - }, - { - "name": "phpspec/prophecy", - "version": "v1.4.1", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", - "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1" - }, - "require-dev": { - "phpspec/phpspec": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2015-04-27 22:15:08" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.1.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5bd48b86cd282da411bb80baac1398ce3fefac41", - "reference": "5bd48b86cd282da411bb80baac1398ce3fefac41", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "~1.0", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-07-26 12:54:47" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2015-06-21 13:08:43" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2015-06-21 08:01:12" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/7a9b0969488c3c54fd62b4d504b3ec758fd005d9", - "reference": "7a9b0969488c3c54fd62b4d504b3ec758fd005d9", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2015-06-19 03:43:16" - }, - { - "name": "phpunit/phpunit", - "version": "4.7.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9b97f9d807b862c2de2a36e86690000801c85724" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b97f9d807b862c2de2a36e86690000801c85724", - "reference": "9b97f9d807b862c2de2a36e86690000801c85724", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "~1.3,>=1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": ">=1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.1", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.2", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.7.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2015-07-13 11:28:34" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/18dfbcb81d05e2296c0bcddd4db96cade75e6f42", - "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "~1.0,>=1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-07-10 06:54:24" - }, - { - "name": "pimple/pimple", - "version": "v2.1.1", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Pimple.git", - "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", - "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1.x-dev" - } - }, - "autoload": { - "psr-0": { - "Pimple": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", - "homepage": "http://pimple.sensiolabs.org", - "keywords": [ - "container", - "dependency injection" - ], - "time": "2014-07-24 07:10:08" - }, - { - "name": "psr/log", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-0": { - "Psr\\Log\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2012-12-21 11:40:51" - }, - { - "name": "satooshi/php-coveralls", - "version": "v0.6.1", - "source": { - "type": "git", - "url": "https://github.com/satooshi/php-coveralls.git", - "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", - "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-simplexml": "*", - "guzzle/guzzle": ">=3.0", - "php": ">=5.3", - "psr/log": "1.0.0", - "symfony/config": ">=2.0", - "symfony/console": ">=2.0", - "symfony/stopwatch": ">=2.2", - "symfony/yaml": ">=2.0" - }, - "require-dev": { - "apigen/apigen": "2.8.*@stable", - "pdepend/pdepend": "dev-master", - "phpmd/phpmd": "dev-master", - "phpunit/php-invoker": ">=1.1.0,<1.2.0", - "phpunit/phpunit": "3.7.*@stable", - "sebastian/finder-facade": "dev-master", - "sebastian/phpcpd": "1.4.*@stable", - "squizlabs/php_codesniffer": "1.4.*@stable", - "theseer/fdomdocument": "dev-master" - }, - "bin": [ - "composer/bin/coveralls" - ], - "type": "library", - "autoload": { - "psr-0": { - "Contrib\\Component": "src/", - "Contrib\\Bundle": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kitamura Satoshi", - "email": "with.no.parachute@gmail.com", - "homepage": "https://www.facebook.com/satooshi.jp" - } - ], - "description": "PHP client library for Coveralls API", - "homepage": "https://github.com/satooshi/php-coveralls", - "keywords": [ - "ci", - "coverage", - "github", - "test" - ], - "time": "2013-05-04 08:07:33" - }, - { - "name": "sebastian/comparator", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2015-07-26 15:48:44" - }, - { - "name": "sebastian/diff", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2015-02-22 15:13:53" - }, - { - "name": "sebastian/environment", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", - "reference": "4fe0a44cddd8cc19583a024bdc7374eb2fef0b87", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2015-07-26 06:42:57" - }, - { - "name": "sebastian/exporter", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2015-06-21 07:55:53" - }, - { - "name": "sebastian/global-state", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", - "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2014-10-06 09:23:50" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", - "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-06-21 08:04:50" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" - }, - { - "name": "symfony/config", - "version": "v2.7.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/Config.git", - "reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/6c905bbed1e728226de656e4c07d620dfe9e80d9", - "reference": "6c905bbed1e728226de656e4c07d620dfe9e80d9", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/filesystem": "~2.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2015-07-09 16:07:40" - }, - { - "name": "symfony/console", - "version": "v2.7.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/8cf484449130cabfd98dcb4694ca9945802a21ed", - "reference": "8cf484449130cabfd98dcb4694ca9945802a21ed", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.1" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2015-07-09 16:07:40" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.7.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", - "reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", - "symfony/stopwatch": "~2.3" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2015-06-18 19:21:56" - }, - { - "name": "symfony/filesystem", - "version": "v2.7.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/2d7b2ddaf3f548f4292df49a99d19c853d43f0b8", - "reference": "2d7b2ddaf3f548f4292df49a99d19c853d43f0b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2015-07-09 16:07:40" - }, - { - "name": "symfony/stopwatch", - "version": "v2.7.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/Stopwatch.git", - "reference": "b07a866719bbac5294c67773340f97b871733310" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/b07a866719bbac5294c67773340f97b871733310", - "reference": "b07a866719bbac5294c67773340f97b871733310", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Stopwatch Component", - "homepage": "https://symfony.com", - "time": "2015-07-01 18:23:16" - }, - { - "name": "symfony/yaml", - "version": "v2.7.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/4bfbe0ed3909bfddd75b70c094391ec1f142f860", - "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2015-07-01 11:25:50" - }, - { - "name": "zeptech/annotations", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/pgraham/php-annotations.git", - "reference": "9cd042daa9ace184d04b49f0605edf73f19a9c71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pgraham/php-annotations/zipball/9cd042daa9ace184d04b49f0605edf73f19a9c71", - "reference": "9cd042daa9ace184d04b49f0605edf73f19a9c71", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "zpt\\anno": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "authors": [ - { - "name": "Philip Graham", - "email": "philip@zeptech.ca" - } - ], - "description": "DOC Block annotation parsing for PHP", - "homepage": "https://github.com/pgraham/php-annotations", - "keywords": [ - "annotations" - ], - "time": "2013-05-29 02:35:23" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "codeclimate/php-test-reporter": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.4" - }, - "platform-dev": { - "ext-sockets": "*" - } -} diff --git a/src/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php index 70950ac9e..a7f4ca7a9 100644 --- a/src/Adapter/GuzzleAdapter.php +++ b/src/Adapter/GuzzleAdapter.php @@ -52,7 +52,7 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface private function get(array $httpMessage) { $endpoint = $this->getHttpQueryEndpoint(); - return $this->httpClient->get($endpoint, $httpMessage)->json(); + return json_decode($this->httpClient->get($endpoint, $httpMessage)->getBody(), true); } protected function getHttpSeriesEndpoint() From 999a95a203687cae7f64a8acfa8492b87a7e3b05 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Thu, 30 Jul 2015 18:45:37 +0200 Subject: [PATCH 156/158] Test against different PHP versions and guzzlehttp versions --- circle.yml | 23 ++++++++++++++++++++++- composer.json | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index f40298150..e577070a1 100644 --- a/circle.yml +++ b/circle.yml @@ -14,12 +14,33 @@ dependencies: - sudo cp ./scripts/influxdb_conf.toml /etc/opt/influxdb/influxdb.conf - sudo /opt/influxdb/influxd -config /etc/opt/influxdb/influxdb.conf: {background: true} - sudo cp scripts/nginx_proxy.conf /etc/nginx/conf.d/proxy.conf - - sudo service nginx restart + - sudo service nginx stop + - sleep 2 + - sudo service nginx start - sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini + override: + - phpenv global 5.6.5 + - composer install --prefer-source --no-interaction + - phpenv global 5.5.21 + - composer install --prefer-source --no-interaction test: override: + - phpenv global 5.6.5 - vendor/bin/phpunit --coverage-clover clover.xml + - composer require guzzlehttp/guzzle:~6 --prefer-source --no-interaction --update-with-dependencies + - vendor/bin/phpunit + - composer require guzzlehttp/guzzle:~5 --prefer-source --no-interaction --update-with-dependencies + - vendor/bin/phpunit + - composer require guzzlehttp/guzzle:~4 --prefer-source --no-interaction --update-with-dependencies + - vendor/bin/phpunit + - phpenv global 5.5.21 + - composer require guzzlehttp/guzzle:~6 --prefer-source --no-interaction --update-with-dependencies + - vendor/bin/phpunit + - composer require guzzlehttp/guzzle:~5 --prefer-source --no-interaction --update-with-dependencies + - vendor/bin/phpunit + - composer require guzzlehttp/guzzle:~4 --prefer-source --no-interaction --update-with-dependencies + - vendor/bin/phpunit post: - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover clover.xml diff --git a/composer.json b/composer.json index 6abce12da..8f65257b5 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Send your app metrics to InfluxDB", "require": { "php": ">=5.4", - "guzzlehttp/guzzle": "~4|~5|~6", + "guzzlehttp/guzzle": "4.2.*", "zendframework/zend-stdlib": "~2", "zendframework/zend-filter": "~2", "zendframework/zend-servicemanager": "~2" From 595b90e96b2beddea4c89d59f4edd6158a9199af Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 31 Jul 2015 10:40:17 +0200 Subject: [PATCH 157/158] Restored guzzlehttp/guzzle version range --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8f65257b5..6abce12da 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Send your app metrics to InfluxDB", "require": { "php": ">=5.4", - "guzzlehttp/guzzle": "4.2.*", + "guzzlehttp/guzzle": "~4|~5|~6", "zendframework/zend-stdlib": "~2", "zendframework/zend-filter": "~2", "zendframework/zend-servicemanager": "~2" From 1928d59eb90bfcba40a957074987c5311afd4e3b Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 31 Jul 2015 10:47:00 +0200 Subject: [PATCH 158/158] Show all dependencies package vesions --- circle.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index e577070a1..4ccd1fe06 100644 --- a/circle.yml +++ b/circle.yml @@ -27,19 +27,24 @@ dependencies: test: override: - phpenv global 5.6.5 - - vendor/bin/phpunit --coverage-clover clover.xml - composer require guzzlehttp/guzzle:~6 --prefer-source --no-interaction --update-with-dependencies - - vendor/bin/phpunit + - composer show -i + - vendor/bin/phpunit --coverage-clover clover.xml - composer require guzzlehttp/guzzle:~5 --prefer-source --no-interaction --update-with-dependencies + - composer show -i - vendor/bin/phpunit - composer require guzzlehttp/guzzle:~4 --prefer-source --no-interaction --update-with-dependencies + - composer show -i - vendor/bin/phpunit - phpenv global 5.5.21 - composer require guzzlehttp/guzzle:~6 --prefer-source --no-interaction --update-with-dependencies + - composer show -i - vendor/bin/phpunit - composer require guzzlehttp/guzzle:~5 --prefer-source --no-interaction --update-with-dependencies + - composer show -i - vendor/bin/phpunit - composer require guzzlehttp/guzzle:~4 --prefer-source --no-interaction --update-with-dependencies + - composer show -i - vendor/bin/phpunit post: - wget https://scrutinizer-ci.com/ocular.phar