TSDuck v3.46-4964
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::InfluxRequest Class Reference

#include <tsInfluxRequest.h>

Inheritance diagram for ts::InfluxRequest:
Collaboration diagram for ts::InfluxRequest:

Public Member Functions

 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 &timestamp)
const WebRequestStatus & status () const

Static Public Member Functions

static int SilentLevel (bool silent, int default_severity=Severity::Error)
static UString ToKey (const UString &name)
static UString ToMeasurement (const UString &name)
static UString ToStringValue (const UString &name)

Detailed Description

Constructor & Destructor Documentation

◆ InfluxRequest() [1/3]

ts::InfluxRequest::InfluxRequest ( const InfluxArgs & args)
explicit

Constructor.

Parameters
[in]argsThe connection information to the InfluxDB server. A reference is kept in this object.

◆ InfluxRequest() [2/3]

ts::InfluxRequest::InfluxRequest ( Report * report,
const InfluxArgs & args )

Constructor.

Parameters
[in]reportWhere 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]argsThe connection information to the InfluxDB server. A reference is kept in this object.

◆ InfluxRequest() [3/3]

ts::InfluxRequest::InfluxRequest ( ReporterBase * delegate,
const InfluxArgs & args )

Constructor.

Parameters
[in]delegateUse the report of another ReporterBase. If delegate is null, log messages are discarded.
[in]argsThe connection information to the InfluxDB server. A reference is kept in this object.

◆ ~InfluxRequest()

virtual ts::InfluxRequest::~InfluxRequest ( )
overridevirtual

Destructor.

Member Function Documentation

◆ start()

void ts::InfluxRequest::start ( const Time & timestamp)

Start building a request to the InfluxDB server.

Parameters
[in]timestampValue 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]measurementThe name of the measurement.
[in]tagsComma-separated list of tags "name=value". The names and values must be compatible with the InfluxDB line protocol (use ToKey() if necessary.
[in]valueThe 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]measurementThe name of the measurement.
[in]tagsComma-separated list of tags "name=value". The names and values must be compatible with the InfluxDB line protocol (use ToKey() if necessary.
[in]fieldsThe 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()

UString ts::InfluxRequest::ToMeasurement ( const UString & name)
inlinestatic

Escape characters in a string to be used as measurement.

Parameters
[in]nameThe name to transform.
Returns
The transformed string with escaped special characters.
See also
https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/

◆ ToKey()

UString ts::InfluxRequest::ToKey ( const UString & name)
inlinestatic

Escape characters in a string to be used as tag key, tag value, or field key.

Parameters
[in]nameThe name to transform.
Returns
The transformed string with escaped special characters.
See also
https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/

◆ ToStringValue()

UString ts::InfluxRequest::ToStringValue ( const UString & name)
inlinestatic

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]nameThe 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]

WebRequestArgs & ts::WebRequest::args ( )
inherited

Access the Web request arguments to get or set them.

Returns
A non-const reference to the Web request arguments.

◆ args() [2/2]

const WebRequestArgs & ts::WebRequest::args ( ) const
inherited

Access the Web request arguments to get them.

Returns
A const reference to the Web request arguments.

◆ status()

const WebRequestStatus & ts::WebRequest::status ( ) const
inherited

Access the Web request status.

Returns
A const reference to the Web request status.

◆ open()

bool ts::WebRequest::open ( const UString & url,
size_t buffer_size = Device::DEFAULT_RECEIVE_BUFFER_SIZE )
inherited

Open an URL and start the transfer. For HTTP request, perform all redirections and get response headers.

Parameters
[in]urlThe complete URL to fetch.
[in]buffer_sizeSize 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]bufferAddress of the buffer for the received data.
[in]max_sizeSize in bytes of the reception buffer.
[out]ret_sizeSize 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()

bool ts::WebRequest::downloadBinaryContent ( const UString & url,
ByteBlockPtr & data,
size_t chunk_size = Device::DEFAULT_RECEIVE_BUFFER_SIZE )
inherited

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]urlThe complete URL to fetch.
[out]dataThe content of the URL in a shred pointer. Null in case of error.
[in]chunk_sizeIndividual download chunk size.
Returns
True on success, false on error.

◆ downloadTextContent()

bool ts::WebRequest::downloadTextContent ( const UString & url,
UString & text,
size_t chunk_size = Device::DEFAULT_RECEIVE_BUFFER_SIZE )
inherited

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]urlThe complete URL to fetch.
[out]textThe content of the URL.
[in]chunk_sizeIndividual download chunk size.
Returns
True on success, false on error.

◆ downloadFile()

bool ts::WebRequest::downloadFile ( const UString & url,
const fs::path & file_name,
size_t chunk_size = Device::DEFAULT_RECEIVE_BUFFER_SIZE )
inherited

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]urlThe complete URL to fetch.
[in]file_nameName of the file to create.
[in]chunk_sizeIndividual 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]

Report * ts::ReporterBase::setReport ( Report * report)
inherited

Associate this object with another Report to log errors.

Parameters
[in]reportWhere 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]

ReporterBase * ts::ReporterBase::setReport ( ReporterBase * delegate)
inherited

Associate this object with another ReporterBase to log errors.

Parameters
[in]delegateUse 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]muteIt 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]silentIf true, do not report errors, report debug messages instead.
[in]default_severityDefault 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: