reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
influxdb.h File Reference

Structures and functions supporting interaction with InfluxDB. More...

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/uio.h>
#include <netdb.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <curl/curl.h>

Go to the source code of this file.

Data Structures

struct  influx_client_t
 InfluxDB client. More...
struct  influx_v2_client_t
 InfluxDB v2 client. More...

Macros

#define _(c)
#define _APPEND(fmter...)
#define _GET_NEXT_CHAR()
#define _GET_NUMBER(n)
#define _LOOP_NEXT(statement)
#define _UNTIL(c)
#define IF_TYPE_ARG_END   0
#define IF_TYPE_FIELD_BOOLEAN   6
#define IF_TYPE_FIELD_FLOAT   4
#define IF_TYPE_FIELD_INTEGER   5
#define IF_TYPE_FIELD_STRING   3
#define IF_TYPE_MEAS   1
#define IF_TYPE_TAG   2
#define IF_TYPE_TIMESTAMP   7
#define INFLUX_END   IF_TYPE_ARG_END
#define INFLUX_F_BOL(k, v)
#define INFLUX_F_FLT(k, v, p)
#define INFLUX_F_INT(k, v)
#define INFLUX_F_STR(k, v)
#define INFLUX_MEAS(m)
#define INFLUX_TAG(k, v)
#define INFLUX_TS(ts)

Typedefs

typedef struct influx_client_t influx_client_t
 InfluxDB client.
typedef struct influx_v2_client_t influx_v2_client_t
 InfluxDB v2 client.

Functions

int _begin_line (char **buf)
int _escaped_append (char **dest, size_t *len, size_t *used, const char *src, const char *escape_seq)
int _format_line (char **buf, va_list ap)
int _format_line2 (char **buf, va_list ap, size_t *, size_t)
int format_line (char **buf, int *len, size_t used,...)
 Format a line for InfluxDB.
int post_curl (influx_v2_client_t *c,...)
 Post a line to InfluxDB via HTTP.
int post_http (influx_client_t *c,...)
 Post a line to InfluxDB via HTTP.
int post_http_send_line (influx_client_t *c, char *buf, int len)
 Post a line to InfluxDB via HTTP.
int send_udp (influx_client_t *c,...)
 Send a line to InfluxDB via UDP.
int send_udp_line (influx_client_t *c, char *line, int len)
 Send a line to InfluxDB via UDP.

Detailed Description

Structures and functions supporting interaction with InfluxDB.

Usage:

INFLUX_MEAS("foo"),
INFLUX_TAG("k", "v"), INFLUX_TAG("k2", "v2"),
INFLUX_F_STR("s", "string"), INFLUX_F_FLT("f", 28.39, 2),
INFLUX_MEAS("bar"),
INFLUX_F_INT("i", 1048576), INFLUX_F_BOL("b", 1),
INFLUX_TS(1512722735522840439),
int send_udp(influx_client_t *c,...)
Send a line to InfluxDB via UDP.
Definition influxdb.h:316
int post_http(influx_client_t *c,...)
Post a line to InfluxDB via HTTP.
Definition influxdb.h:274
#define INFLUX_F_BOL(k, v)
Definition influxdb.h:41
#define INFLUX_F_INT(k, v)
Definition influxdb.h:40
#define INFLUX_END
Definition influxdb.h:43
#define INFLUX_MEAS(m)
Definition influxdb.h:36
#define INFLUX_TS(ts)
Definition influxdb.h:42
#define INFLUX_F_FLT(k, v, p)
Definition influxdb.h:39
#define INFLUX_F_STR(k, v)
Definition influxdb.h:38
#define INFLUX_TAG(k, v)
Definition influxdb.h:37

NOTICE**: For best performance you should sort tags by key before sending them to the database. The sort should match the results from the Go bytes.Compare function.

Macro Definition Documentation

◆ _

#define _ ( c)
Value:
if ((_GET_NEXT_CHAR()) != c) \
break;
#define _GET_NEXT_CHAR()

◆ _APPEND

#define _APPEND ( fmter...)
Value:
for (;;) { \
if ((written = snprintf(*buf + used, len - used, ##fmter)) < 0) \
goto FAIL; \
if (used + written >= len && !(*buf = (char*)realloc(*buf, len *= 2))) \
return -1; \
else { \
used += written; \
break; \
} \
}

◆ _GET_NEXT_CHAR

#define _GET_NEXT_CHAR ( )
Value:
(ch = (len >= (int)iv[0].iov_len && \
(iv[0].iov_len = recv(sock, iv[0].iov_base, iv[0].iov_len, len = 0)) == (size_t)(-1) \
? 0 \
: *((char*)iv[0].iov_base + len++)))

◆ _GET_NUMBER

#define _GET_NUMBER ( n)
Value:
_LOOP_NEXT(if (ch >= '0' && ch <= '9') n = n * 10 + (ch - '0'); else break;)
#define _LOOP_NEXT(statement)

◆ _LOOP_NEXT

#define _LOOP_NEXT ( statement)
Value:
for (;;) { \
if (!(_GET_NEXT_CHAR())) { \
ret_code = -8; \
goto END; \
} \
statement \
}

◆ _UNTIL

#define _UNTIL ( c)
Value:
_LOOP_NEXT(if (ch == c) break;)

◆ IF_TYPE_ARG_END

#define IF_TYPE_ARG_END   0

◆ IF_TYPE_FIELD_BOOLEAN

#define IF_TYPE_FIELD_BOOLEAN   6

◆ IF_TYPE_FIELD_FLOAT

#define IF_TYPE_FIELD_FLOAT   4

◆ IF_TYPE_FIELD_INTEGER

#define IF_TYPE_FIELD_INTEGER   5

◆ IF_TYPE_FIELD_STRING

#define IF_TYPE_FIELD_STRING   3

◆ IF_TYPE_MEAS

#define IF_TYPE_MEAS   1

◆ IF_TYPE_TAG

#define IF_TYPE_TAG   2

◆ IF_TYPE_TIMESTAMP

#define IF_TYPE_TIMESTAMP   7

◆ INFLUX_END

#define INFLUX_END   IF_TYPE_ARG_END

◆ INFLUX_F_BOL

#define INFLUX_F_BOL ( k,
v )
Value:
IF_TYPE_FIELD_BOOLEAN, (k), ((v) ? 1 : 0)
#define IF_TYPE_FIELD_BOOLEAN
Definition influxdb.h:121

◆ INFLUX_F_FLT

#define INFLUX_F_FLT ( k,
v,
p )
Value:
IF_TYPE_FIELD_FLOAT, (k), (double)(v), (int)(p)
#define IF_TYPE_FIELD_FLOAT
Definition influxdb.h:119

◆ INFLUX_F_INT

#define INFLUX_F_INT ( k,
v )
Value:
IF_TYPE_FIELD_INTEGER, (k), (long long)(v)
#define IF_TYPE_FIELD_INTEGER
Definition influxdb.h:120

◆ INFLUX_F_STR

#define INFLUX_F_STR ( k,
v )
Value:
#define IF_TYPE_FIELD_STRING
Definition influxdb.h:118

◆ INFLUX_MEAS

#define INFLUX_MEAS ( m)
Value:
#define IF_TYPE_MEAS
Definition influxdb.h:116

◆ INFLUX_TAG

#define INFLUX_TAG ( k,
v )
Value:
IF_TYPE_TAG, (k), (v)
#define IF_TYPE_TAG
Definition influxdb.h:117

◆ INFLUX_TS

#define INFLUX_TS ( ts)
Value:
IF_TYPE_TIMESTAMP, (long long)(ts)
#define IF_TYPE_TIMESTAMP
Definition influxdb.h:122

Function Documentation

◆ _begin_line()

int _begin_line ( char ** buf)

◆ _escaped_append()

int _escaped_append ( char ** dest,
size_t * len,
size_t * used,
const char * src,
const char * escape_seq )

◆ _format_line()

int _format_line ( char ** buf,
va_list ap )

◆ _format_line2()

int _format_line2 ( char ** buf,
va_list ap,
size_t * _len,
size_t used )