API
#github.com/xulang-org/packages/etcd
Xu 0.8.8 API
import: etcd #github.com/xulang-org/packages/etcd
counts: 4 fns, 19 methods, 3 types, 0 consts, 0 ifaces
etcd v3 Cloud-Native Distributed Key-Value & Coordination Driver for Xu Features Native HTTP/JSON communication with etcd v3 gRPC-Gateway. Standard Base64 Key-Value storage (put, get, delete). Distributed Lease lifecycle (lease_grant, lease_revoke, lease_keepalive). Connection pooling via reusable TCP socket channels.
github.com/xulang-org/packages · 0.1.1 · Install and use
open
pub fn open(endpoint string) Client
Purpose
etcd v3 Cloud-Native Distributed Key-Value & Coordination Driver for Xu Features Native HTTP/JSON communication with etcd v3 gRPC-Gateway. Standard Base64 Key-Value storage (put, get, delete). Distributed Lease lifecycle (lease_grant, lease_revoke, lease_keepalive). Connection pooling via reusable TCP socket channels.
Parameters
endpoint string- endpoint (string)
Returns
Client — a value of this type
open_pool
pub fn open_pool(endpoint string, max_idle int) Pool
Purpose
Open pool.
Parameters
endpoint string- endpoint (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
}
Purpose
Public struct `Client`.
Parameters
host string- host
port int- port
new_client
pub fn new_client(endpoint string) Client
Purpose
Construct client.
Parameters
endpoint string- endpoint (string)
Returns
Client — a value of this type
(&mut Client) request
pub fn (c &mut Client) request(path string, body_json string) Response
Purpose
Call `request` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
path string- filesystem path (string)
body_json string- body_json (string)
Returns
Response — a value of this type
(&mut Client) put
pub fn (c &mut Client) put(key string, value string) int
Purpose
Call `put` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
value string- value (string)
Returns
int — a value of this type
(&mut Client) put_with_lease
pub fn (c &mut Client) put_with_lease(key string, value string, lease_id int) int
Purpose
Method on `&mut Client`: put with lease. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
value string- value (string)
lease_id int- lease_id (int)
Returns
int — a value of this type
(&mut Client) get
pub fn (c &mut Client) get(key string) string
Purpose
Call `get` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
Returns
string — result string
(&mut Client) exists
pub fn (c &mut Client) exists(key string) bool
Purpose
Call `exists` on `&mut Client`.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
Returns
bool — true or false
(&mut Client) delete
pub fn (c &mut Client) delete(key string) int
Purpose
Call `delete` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
Returns
int — a value of this type
(&mut Client) lease_grant
pub fn (c &mut Client) lease_grant(ttl_seconds int) int
Purpose
Method on `&mut Client`: lease grant. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
ttl_seconds int- ttl_seconds (int)
Returns
int — a value of this type
(&mut Client) lease_revoke
pub fn (c &mut Client) lease_revoke(lease_id int) int
Purpose
Method on `&mut Client`: lease revoke. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
lease_id int- lease_id (int)
Returns
int — a value of this type
(&mut Client) lease_keepalive
pub fn (c &mut Client) lease_keepalive(lease_id int) int
Purpose
Method on `&mut Client`: lease keepalive. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
lease_id int- lease_id (int)
Returns
int — a value of this type
struct Pool
pub struct Pool {
pub host string
pub port int
pub endpoint string
pub state chan pool.State
pub max_idle int
}
Purpose
Connection Pool for etcd v3. Manages reusable TCP/HTTP socket connections.
Parameters
host string- host
port int- port
endpoint 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, max_idle int) Pool
Purpose
Construct pool.
Parameters
endpoint string- endpoint (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) put
pub fn (p &Pool) put(key string, value string) int
Purpose
Call `put` on `&Pool`. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
key string- key (string)
value string- value (string)
Returns
int — a value of this type
(&Pool) get_key
pub fn (p &Pool) get_key(key string) string
Purpose
Method on `&Pool`: read key. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
key string- key (string)
Returns
string — result string
(&Pool) delete
pub fn (p &Pool) delete(key string) int
Purpose
Call `delete` on `&Pool`. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
key string- key (string)
Returns
int — a value of this type
(&Pool) exists
pub fn (p &Pool) exists(key string) bool
Purpose
Call `exists` on `&Pool`.
Parameters
p &Pool- receiver &Pool (borrow)
key string- key (string)
Returns
bool — true or false
(&Pool) close
Purpose
Method on `&Pool`: close the resource.
Parameters
p &Pool- receiver &Pool (borrow)