API
#github.com/xulang-org/packages/influxdb
Xu 0.8.8 API
import: influxdb #github.com/xulang-org/packages/influxdb
counts: 6 fns, 25 methods, 6 types, 0 consts, 0 ifaces
InfluxDB v2 Time-Series Database Driver for Xu Features Native HTTP/1.1 REST communication via Xu standard library. Full support for InfluxDB Line Protocol point creation and batch writing. Flux script query support with annotated CSV output. Server health check & ping endpoints. Reusable HTTP connections with shared borrow/return and close state. Full compatibility with InfluxDB 2.x+.
github.com/xulang-org/packages · 0.1.1 · Install and use
open
pub fn open(endpoint string, token string, org string, bucket string) Client
Purpose
InfluxDB v2 Time-Series Database Driver for Xu Features Native HTTP/1.1 REST communication via Xu standard library. Full support for InfluxDB Line Protocol point creation and batch writing. Flux script query support with annotated CSV output. Server health check & ping endpoints. Reusable HTTP connections with shared borrow/return and close state. Full compatibility with InfluxDB 2.x+.
Parameters
endpoint string- endpoint (string)
token string- token (string)
org string- org (string)
bucket string- bucket (string)
Returns
Client — a value of this type
open_pool_client
pub fn open_pool_client(endpoint string, token string, org string, bucket string, max_idle int) Pool
Purpose
Open pool client.
Parameters
endpoint string- endpoint (string)
token string- token (string)
org string- org (string)
bucket string- bucket (string)
max_idle int- max_idle (int)
Returns
Pool — a value of this type
struct Response
pub struct Response {
pub status_code int
pub body string
}
Purpose
Public struct `Response`.
Parameters
status_code int- field (int)
body string- body
struct Client
pub struct Client {
pub host string
pub port int
pub token string
pub org string
pub bucket string
}
Purpose
Public struct `Client`.
Parameters
host string- host
port int- port
token string- field (string)
org string- field (string)
bucket string- field (string)
new_client
pub fn new_client(endpoint string, token string, org string, bucket string) Client
Purpose
Construct client.
Parameters
endpoint string- endpoint (string)
token string- token (string)
org string- org (string)
bucket string- bucket (string)
Returns
Client — a value of this type
(&mut Client) request
pub fn (c &mut Client) request(method string, path string, body string, content_type string, accept string) Response
Purpose
Call `request` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
method string- method (string)
path string- filesystem path (string)
body string- body (string)
content_type string- content_type (string)
accept string- accept (string)
Returns
Response — a value of this type
struct Tag
pub struct Tag {
pub key string
pub val string
}
Purpose
Public struct `Tag`.
Parameters
key string- key
val string- value
struct Field
pub struct Field {
pub key string
pub val string
}
Purpose
Public struct `Field`.
Parameters
key string- key
val string- value
struct Point
pub struct Point {
pub measurement string
pub tags []Tag
pub fields []Field
pub timestamp int
}
Purpose
Public struct `Point`.
Parameters
measurement string- field (string)
tags []Tag- field ([]Tag)
fields []Field- field ([]Field)
timestamp int- field (int)
new_point
pub fn new_point(measurement string) Point
Purpose
Construct point.
Parameters
measurement string- measurement (string)
Returns
Point — a value of this type
(&mut Point) add_tag
pub fn (p &mut Point) add_tag(key string, val string)
Purpose
Method on `&mut Point`: add tag.
Parameters
p &mut Point- receiver &mut Point (exclusive borrow)
key string- key (string)
val string- value (string)
(&mut Point) add_field_string
pub fn (p &mut Point) add_field_string(key string, val string)
Purpose
Method on `&mut Point`: add field string.
Parameters
p &mut Point- receiver &mut Point (exclusive borrow)
key string- key (string)
val string- value (string)
(&mut Point) add_field_int
pub fn (p &mut Point) add_field_int(key string, val int)
Purpose
Method on `&mut Point`: add field int.
Parameters
p &mut Point- receiver &mut Point (exclusive borrow)
key string- key (string)
val int- value (int)
(&mut Point) add_field_float
pub fn (p &mut Point) add_field_float(key string, val string)
Purpose
Method on `&mut Point`: add field float.
Parameters
p &mut Point- receiver &mut Point (exclusive borrow)
key string- key (string)
val string- value (string)
(&mut Point) add_field_bool
pub fn (p &mut Point) add_field_bool(key string, val bool)
Purpose
Method on `&mut Point`: add field bool.
Parameters
p &mut Point- receiver &mut Point (exclusive borrow)
key string- key (string)
val bool- value (bool)
(&mut Point) set_timestamp
pub fn (p &mut Point) set_timestamp(ts int)
Purpose
Method on `&mut Point`: set timestamp.
Parameters
p &mut Point- receiver &mut Point (exclusive borrow)
ts int- ts (int)
(&Point) to_line
pub fn (p &Point) to_line() string
Purpose
Method on `&Point`: convert to line.
Parameters
p &Point- receiver &Point (borrow)
Returns
string — result string
(&mut Client) write_point
pub fn (c &mut Client) write_point(point Point) bool
Purpose
Method on `&mut Client`: write point. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
point Point- point (Point)
Returns
bool — true or false
(&mut Client) write_line
pub fn (c &mut Client) write_line(line string) bool
Purpose
Method on `&mut Client`: write line. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
line string- line (string)
Returns
bool — true or false
(&mut Client) write_raw
pub fn (c &mut Client) write_raw(lines string) bool
Purpose
Method on `&mut Client`: write raw. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
lines string- lines (string)
Returns
bool — true or false
struct Pool
pub struct Pool {
pub host string
pub port int
pub token string
pub org string
pub bucket string
pub state chan pool.State
pub max_idle int
}
Purpose
Connection Pool for InfluxDB v2. Manages reusable TCP socket connections and provides Client instances.
Parameters
host string- host
port int- port
token string- field (string)
org string- field (string)
bucket string- field (string)
state chan pool.State- field (channel; type chan pool.State)
max_idle int- field (int)
new_pool
pub fn new_pool(endpoint string, token string, org string, bucket string, max_idle int) Pool
Purpose
Construct pool.
Parameters
endpoint string- endpoint (string)
token string- token (string)
org string- org (string)
bucket string- bucket (string)
max_idle int- max_idle (int)
Returns
Pool — a value of this type
open_pool
pub fn open_pool(endpoint string, token string, org string, bucket string, max_idle int) Pool
Purpose
Open pool.
Parameters
endpoint string- endpoint (string)
token string- token (string)
org string- org (string)
bucket string- bucket (string)
max_idle int- max_idle (int)
Returns
Pool — a value of this type
(&Pool) get
pub fn (p &Pool) get() Client
Purpose
Call `get` on `&Pool`.
Parameters
p &Pool- receiver &Pool (borrow)
Returns
Client — a value of this type
(&Pool) dup
pub fn (p &Pool) dup() Pool
Purpose
Shares sockets and close state; clones configuration strings.
Parameters
p &Pool- receiver &Pool (borrow)
Returns
Pool — a value of this type
(&Pool) get_conn
pub fn (p &Pool) get_conn() int
Purpose
Method on `&Pool`: read conn.
Parameters
p &Pool- receiver &Pool (borrow)
Returns
int — a value of this type
(&Pool) put_conn
pub fn (p &Pool) put_conn(fd int)
Purpose
Method on `&Pool`: put connection.
Parameters
p &Pool- receiver &Pool (borrow)
fd int- file descriptor (int)
(&Pool) discard_conn
pub fn (p &Pool) discard_conn(fd int)
Purpose
Method on `&Pool`: discard connection.
Parameters
p &Pool- receiver &Pool (borrow)
fd int- file descriptor (int)
(&Pool) write_point
pub fn (p &Pool) write_point(point Point) bool
Purpose
Method on `&Pool`: write point. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
point Point- point (Point)
Returns
bool — true or false
(&Pool) write_line
pub fn (p &Pool) write_line(line string) bool
Purpose
Method on `&Pool`: write line. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
line string- line (string)
Returns
bool — true or false
(&Pool) write_raw
pub fn (p &Pool) write_raw(lines string) bool
Purpose
Method on `&Pool`: write raw. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
lines string- lines (string)
Returns
bool — true or false
(&Pool) query_flux
pub fn (p &Pool) query_flux(flux string) string
Purpose
Method on `&Pool`: query flux. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
flux string- flux (string)
Returns
string — result string
(&Pool) ping
pub fn (p &Pool) ping() bool
Purpose
Call `ping` on `&Pool`. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
Returns
bool — true or false
(&Pool) close
Purpose
Method on `&Pool`: close the resource.
Parameters
p &Pool- receiver &Pool (borrow)
(&mut Client) health
pub fn (c &mut Client) health() bool
Purpose
Call `health` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
bool — true or false
(&mut Client) ping
pub fn (c &mut Client) ping() bool
Purpose
Call `ping` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
bool — true or false
(&mut Client) query_flux
pub fn (c &mut Client) query_flux(flux string) string
Purpose
Method on `&mut Client`: query flux. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
flux string- flux (string)
Returns
string — result string