\TinyInflux
Implements lightweight InfluxDB client API
Synopsis
class TinyInflux
{
- // members
- protected string $baseUrl = '';
- protected integer $timeout = 2;
- protected string $database = '';
- protected string $user = '';
- protected string $password = '';
- protected string $precision = 'ns';
- protected integer $version = 1;
- protected string $org = '';
- protected string $bucket = '';
- protected string $token = '';
- // methods
- public void __construct()
- public void setV2Params()
- public bool writePoint()
- public mixed query()
- protected bool isDdlQuery()
- protected array doRequest()
- protected string buildLineProtocol()
- protected string normalizeTimestamp()
- protected string escapeKey()
- protected string escapeTagValue()
- protected string formatFieldValue()
Members
protected
- $baseUrl
—
string
InfluxDB HTTP API base URL without trailing slash - $bucket
—
string
InfluxDB v2 bucket - $database
—
string
InfluxDB database name - $org
—
string
InfluxDB v2 organization - $password
—
string
InfluxDB user password - $precision
—
string
Default timestamp precision - $timeout
—
int
Default connection timeout in seconds - $token
—
string
InfluxDB v2 auth token - $user
—
string
InfluxDB user name - $version
—
int
InfluxDB API version: 1 or 2
Methods
protected
- buildLineProtocol() — Builds InfluxDB line protocol string for single point
- doRequest() — Performs low-level HTTP request via cURL
- escapeKey() — Escapes measurement, tag key or field key
- escapeTagValue() — Escapes tag value
- formatFieldValue() — Formats field value according to InfluxDB line protocol rules
- isDdlQuery() — Returns true if the query is DDL and should be sent via POST (InfluxDB v1)
- normalizeTimestamp() — Converts timestamp to InfluxDB line protocol format (integer in configured precision).
public
- __construct() — Creates new TinyInflux instance
- query() — Performs simple query against InfluxDB and returns raw response or parsed JSON
- setV2Params() — Sets InfluxDB v2 specific parameters
- writePoint() — Writes single point to InfluxDB