From 4fa039337b27f29d31f5d2a8d2a7acd5188a3a08 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Mon, 8 Jun 2015 19:05:14 +0200 Subject: [PATCH] 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(