/**
* Writes points into InfluxDB
*
* @param Point[] $points Array of points
* @param string $precision The timestamp precision (defaults to nanoseconds)
* @return bool
* @throws Exception
*/
public function writePoints(array $points, $precision = self::PRECISION_NANOSECONDS)
{
$payload = array_map(function (Point $point) {
return (string) $point;
}, $points);
try {
$driver = $this->client->getDriver();
$driver->setParameters(['url' => sprintf('write?db=%s&precision=%s', $this->name, $precision), 'database' => $this->name, 'method' => 'post']);
// send the points to influxDB
$driver->write(implode(PHP_EOL, $payload));
return $driver->isSuccess();
} catch (\Exception $e) {
throw new Exception('Writing has failed', $e->getCode(), $e);
}
}