nidas
v1.2-1520
|
Methods and memory for creating an Influx database, accumulating measurements, and posting them to the database. More...
Public Member Functions | |
InfluxDB (const std::string &url="", const std::string &dbname="") | |
bool | isOpen () |
void | open () |
Initialize for http database connections. More... | |
void | setURL (const std::string &url) |
void | setDatabase (const std::string &dbname) |
std::string | getDatabase () |
void | setUser (const std::string &username, const std::string &passwordfile) |
Set username to use for the http connection. More... | |
std::string | getAuth (const std::string &prefix="") |
void | setCount (unsigned int count) |
void | setEcho (bool echo) |
If echo is true, the data posted to the database is printed on stdout instead of being written to the database. More... | |
void | setAsync (bool enable) |
If enable is true, data will be posted to the database asynchronously. More... | |
~InfluxDB () | |
std::string | getHostURL () |
std::string | getWriteURL () |
std::string | getErrors () |
bool | addMeasurement (const std::string &data) |
Return false if there is an error adding this measurement. More... | |
bool | sendData () |
unsigned int | totalMeasurements () |
Return the total number of measurements written to the database so far. More... | |
void | flush () |
Send whatever is left in the current buffer and wait for it to finish. More... | |
void | createInfluxDB () |
void | handleResult (CURLcode res) |
Private Member Functions | |
InfluxDB (const InfluxDB &) | |
InfluxDB & | operator= (const InfluxDB &) |
Private Attributes | |
string | _url |
string | _dbname |
string | _username |
string | _password |
CharBuffer * | _data |
CharBuffer | _data1 |
CharBuffer | _data2 |
CharBuffer | _result |
string | _errs |
unsigned int | _nmeasurements |
unsigned int | _total_measurements |
unsigned int | _count |
bool | _echo |
bool | _async |
CURL * | _curl |
char | _curl_errors [CURL_ERROR_SIZE] |
std::future< CURLcode > | _post |
Methods and memory for creating an Influx database, accumulating measurements, and posting them to the database.
The host URL is something like "http://snoopy.eol.ucar.edu:8086"
The database URL is formed like "<url>/write?db=<dbname>&precision=u"
|
inline |
|
inline |
|
private |
|
inline |
Return false if there is an error adding this measurement.
If enough measurements have accumulated, then this will post the current buffer to the database. If there is an error, the description will be in getError().
References VLOG.
void InfluxDB::createInfluxDB | ( | ) |
References ILOG.
|
inline |
Send whatever is left in the current buffer and wait for it to finish.
References ILOG.
|
inline |
References prefix.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
References DLOG.
|
inline |
|
inline |
Initialize for http database connections.
No database actions can be performed before this initialization happens, but the initialization only happens once. This will be called implicitly by other methods which need http. Do not call it if the database will not actually be used, such as when echo is enabled.
References writeInfluxResult().
|
inline |
References dataToInfluxDB(), and DLOG.
|
inline |
If enable
is true, data will be posted to the database asynchronously.
|
inline |
|
inline |
|
inline |
If echo
is true, the data posted to the database is printed on stdout instead of being written to the database.
|
inline |
|
inline |
Set username
to use for the http connection.
If passwordfile
is not empty, then open the file at the given path to read the password.
References ILOG.
|
inline |
Return the total number of measurements written to the database so far.
This does not include the measurements currently in the buffer and not yet written.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |