XU XUv0.8.8
中文

API

#github.com/xulang-org/packages/influxdb

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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub struct Tag {
    pub key string
    pub val string
}

Purpose

Public struct `Tag`.

Parameters

key string
key
val string
value

struct Field

XuAPI
pub struct Field {
    pub key string
    pub val string
}

Purpose

Public struct `Field`.

Parameters

key string
key
val string
value

struct Point

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn (p &Pool) close()

Purpose

Method on `&Pool`: close the resource.

Parameters

p &Pool
receiver &Pool (borrow)

(&mut Client) health

XuAPI
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

XuAPI
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

XuAPI
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