예제 #1
0
 /**
  * Write a payload into InfluxDB using the current driver. This method is similar to <tt>writePoints()</tt>,
  * except it takes a string payload instead of an array of Points. This is useful in the following situations:
  *
  *   1) Performing unique queries that may not conform to the current Point standard.
  *   2) Inserting very large set of points into a measurement where looping via array_map() actually
  *      hurts performance as the payload may be calculated in advance by caller.
  *
  * @param  string|array  $payload          InfluxDB payload (Or array of payloads) that conform to the Line syntax.
  * @param  string        $precision        The timestamp precision (defaults to nanoseconds).
  * @param  string|null   $retentionPolicy  Specifies an explicit retention policy to use when writing all points. If
  *                                         not set, the default retention period will be used. This is only
  *                                         applicable for the Guzzle driver. The UDP driver utilizes the endpoint
  *                                         configuration defined in the server's influxdb configuration file.
  * @return Observable
  * @throws \Rxnet\InfluxDB\Exception
  */
 public function writePayload($payload, $precision = self::PRECISION_NANOSECONDS, $retentionPolicy = null)
 {
     try {
         $parameters = ['url' => sprintf('write?db=%s&precision=%s', $this->name, $precision), 'database' => $this->name, 'method' => 'post'];
         if ($retentionPolicy !== null) {
             $parameters['url'] .= sprintf('&rp=%s', $retentionPolicy);
         }
         return $this->client->write($parameters, $payload);
     } catch (Exception $e) {
         throw new InfluxDBException($e->getMessage(), $e->getCode());
     }
 }