#include <tsInfluxRequest.h>
|
| | InfluxRequest (const InfluxArgs &args) |
| | InfluxRequest (Report *report, const InfluxArgs &args) |
| | InfluxRequest (ReporterBase *delegate, const InfluxArgs &args) |
| virtual | ~InfluxRequest () override |
| void | abort () |
| void | add (const UString &measurement, const UString &tags, const UString &fields) |
template<typename INT_T>
requires std::integral<INT_T> |
| void | add (const UString &measurement, const UString &tags, INT_T value) |
| WebRequestArgs & | args () |
| const WebRequestArgs & | args () const |
| bool | close () |
| const UString & | currentContent () const |
| bool | downloadBinaryContent (const UString &url, ByteBlockPtr &data, size_t chunk_size=Device::DEFAULT_RECEIVE_BUFFER_SIZE) |
| bool | downloadFile (const UString &url, const fs::path &file_name, size_t chunk_size=Device::DEFAULT_RECEIVE_BUFFER_SIZE) |
| bool | downloadTextContent (const UString &url, UString &text, size_t chunk_size=Device::DEFAULT_RECEIVE_BUFFER_SIZE) |
| bool | isOpen () const |
| bool | muteReport (bool mute) |
| bool | open (const UString &url, size_t buffer_size=Device::DEFAULT_RECEIVE_BUFFER_SIZE) |
| bool | receive (void *buffer, size_t max_size, size_t &ret_size) |
| virtual Report & | report () const override |
| bool | send () |
| Report * | setReport (Report *report) |
| ReporterBase * | setReport (ReporterBase *delegate) |
| void | start (const Time ×tamp) |
| const WebRequestStatus & | status () const |
◆ InfluxRequest() [1/3]
| ts::InfluxRequest::InfluxRequest |
( |
const InfluxArgs & | args | ) |
|
|
explicit |
Constructor.
- Parameters
-
| [in] | args | The connection information to the InfluxDB server. A reference is kept in this object. |
◆ InfluxRequest() [2/3]
Constructor.
- Parameters
-
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
| [in] | args | The connection information to the InfluxDB server. A reference is kept in this object. |
◆ InfluxRequest() [3/3]
Constructor.
- Parameters
-
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, log messages are discarded. |
| [in] | args | The connection information to the InfluxDB server. A reference is kept in this object. |
◆ ~InfluxRequest()
| virtual ts::InfluxRequest::~InfluxRequest |
( |
| ) |
|
|
overridevirtual |
◆ start()
| void ts::InfluxRequest::start |
( |
const Time & | timestamp | ) |
|
Start building a request to the InfluxDB server.
- Parameters
-
| [in] | timestamp | Value of the timestamp for that request. |
◆ add() [1/2]
template<typename INT_T>
requires std::integral<INT_T>
| void ts::InfluxRequest::add |
( |
const UString & | measurement, |
|
|
const UString & | tags, |
|
|
INT_T | value ) |
|
inline |
Add a line in the request being built, with one single integer value.
- Parameters
-
| [in] | measurement | The name of the measurement. |
| [in] | tags | Comma-separated list of tags "name=value". The names and values must be compatible with the InfluxDB line protocol (use ToKey() if necessary. |
| [in] | value | The measurement value. The field name is implicitly "value". |
◆ add() [2/2]
| void ts::InfluxRequest::add |
( |
const UString & | measurement, |
|
|
const UString & | tags, |
|
|
const UString & | fields ) |
Add a line in the request being built, with generic value fields.
- Parameters
-
| [in] | measurement | The name of the measurement. |
| [in] | tags | Comma-separated list of tags "name=value". The names and values must be compatible with the InfluxDB line protocol (use ToKey() if necessary. |
| [in] | fields | The measurement fields. The field names and values must be compatible with the InfluxDB line protocol. |
◆ currentContent()
| const UString & ts::InfluxRequest::currentContent |
( |
| ) |
const |
|
inline |
Get the current content of the request being built. For debug purpose only.
- Returns
- A constant reference to a string object containing the currnet content.
◆ send()
| bool ts::InfluxRequest::send |
( |
| ) |
|
Complete the request being built and send it to the InfluxDB server.
- Returns
- True on success, false on error.
◆ ToMeasurement()
◆ ToKey()
◆ ToStringValue()
Escape characters in a string to be used as field value of type string. Do not use for numerical field values. This function adds surrounding quotes.
- Parameters
-
| [in] | name | The name to transform. |
- Returns
- The transformed string with escaped special characters and surrounding quotes.
- See also
- https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/
◆ args() [1/2]
Access the Web request arguments to get or set them.
- Returns
- A non-const reference to the Web request arguments.
◆ args() [2/2]
Access the Web request arguments to get them.
- Returns
- A const reference to the Web request arguments.
◆ status()
Access the Web request status.
- Returns
- A const reference to the Web request status.
◆ open()
Open an URL and start the transfer. For HTTP request, perform all redirections and get response headers.
- Parameters
-
| [in] | url | The complete URL to fetch. |
| [in] | buffer_size | Size of input buffers to receive data. |
- Returns
- True on success, false on error.
◆ isOpen()
| bool ts::WebRequest::isOpen |
( |
| ) |
const |
|
inherited |
Check if a transfer is open.
- Returns
- True if a transfer is open, false otherwise.
◆ receive()
| bool ts::WebRequest::receive |
( |
void * | buffer, |
|
|
size_t | max_size, |
|
|
size_t & | ret_size ) |
|
inherited |
Receive data.
- Parameters
-
| [out] | buffer | Address of the buffer for the received data. |
| [in] | max_size | Size in bytes of the reception buffer. |
| [out] | ret_size | Size in bytes of the received data. Will never be larger than max_size. When ret_size is zero, this is the end of the transfer. |
- Returns
- True on success, false on error. A successful end of transfer is reported when ret_size is zero and the returned value is true.
◆ close()
| bool ts::WebRequest::close |
( |
| ) |
|
|
inherited |
Close the transfer.
- Returns
- True on success, false on error.
◆ abort()
| void ts::WebRequest::abort |
( |
| ) |
|
|
inherited |
Abort a transfer in progress. Can be called from another thread.
◆ downloadBinaryContent()
Download the content of the URL as binary data in one operation. The open/read/close session is embedded in this method. The request must be in blocking mode (the default).
- Parameters
-
| [in] | url | The complete URL to fetch. |
| [out] | data | The content of the URL in a shred pointer. Null in case of error. |
| [in] | chunk_size | Individual download chunk size. |
- Returns
- True on success, false on error.
◆ downloadTextContent()
Download the content of the URL as text in one operation. The open/read/close session is embedded in this method.. The downloaded text is converted from UTF-8. End of lines are normalized as LF. The request must be in blocking mode (the default).
- Parameters
-
| [in] | url | The complete URL to fetch. |
| [out] | text | The content of the URL. |
| [in] | chunk_size | Individual download chunk size. |
- Returns
- True on success, false on error.
◆ downloadFile()
Download the content of the URL in a file in one operation. The open/read/close session is embedded in this method.. No transformation is applied to the data. The request must be in blocking mode (the default).
- Parameters
-
| [in] | url | The complete URL to fetch. |
| [in] | file_name | Name of the file to create. |
| [in] | chunk_size | Individual download chunk size. |
- Returns
- True on success, false on error.
◆ report()
| virtual Report & ts::ReporterBase::report |
( |
| ) |
const |
|
overridevirtualinherited |
Access the Report which is associated with this object. Can be called from another thread only if the Report object is thread-safe.
- Returns
- A reference to the associated report.
Implements ts::ReporterInterface.
◆ setReport() [1/2]
Associate this object with another Report to log errors.
- Parameters
-
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
- Returns
- The address of the previous Report object or a null pointer if there was none.
◆ setReport() [2/2]
Associate this object with another ReporterBase to log errors.
- Parameters
-
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, the previous explicit Report is used.. |
- Returns
- The address of the previous ReporterBase object or a null pointer if there was none.
◆ muteReport()
| bool ts::ReporterBase::muteReport |
( |
bool | mute | ) |
|
|
inherited |
Temporarily mute the associated report.
- Parameters
-
| [in] | mute | It true, report() will return a null report (log messages are discarded), until muteReport() is invoked again with mute set to false. |
- Returns
- Previous state of the mute field.
◆ SilentLevel()
| int ts::ReporterBase::SilentLevel |
( |
bool | silent, |
|
|
int | default_severity = Severity::Error ) |
|
inlinestaticinherited |
Compute a log severity level from a "silent" parameter. Some subclass methods have a "silent" parameter to avoid reporting errors which may be insignificant, typically when closing a device after an error, in which case the close operation may produce other errors if the previous error left the device in an inconsistent state. While those errors should not be displayed as errors, we still display them at debug level.
- Parameters
-
| [in] | silent | If true, do not report errors, report debug messages instead. |
| [in] | default_severity | Default severity, in non-silent mode (error by default). |
- Returns
- Error when silent is false, Debug otherwise.
The documentation for this class was generated from the following file: