mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Merge pull request #30 from corley/feature/allows-non-write-adapters
Allows non write adapters
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
namespace InfluxDB\Adapter;
|
||||
|
||||
/**
|
||||
* Every InfluxDB adapter implements this interface
|
||||
*/
|
||||
interface AdapterInterface
|
||||
{
|
||||
/**
|
||||
* Send series into database
|
||||
* @param mixed $message
|
||||
* @param string|boolean $timePrecision
|
||||
*/
|
||||
public function send(array $message);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace InfluxDB\Adapter;
|
||||
|
||||
interface WritableInterface
|
||||
{
|
||||
public function send(array $message);
|
||||
}
|
||||
+6
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace InfluxDB;
|
||||
|
||||
use InfluxDB\Adapter\WritableInterface;
|
||||
use InfluxDb\Adapter\QueryableInterface;
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ class Client
|
||||
{
|
||||
private $adapter;
|
||||
|
||||
public function __construct(Adapter\AdapterInterface $adapter)
|
||||
public function __construct($adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
@@ -23,6 +24,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 =[];
|
||||
|
||||
Reference in New Issue
Block a user