XU XUv0.8.8
EN

API

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

import: etcd #github.com/xulang-org/packages/etcd

counts: 4 函数, 19 方法, 3 类型, 0 常量, 0 方法集

扩展包 `etcd #github.com/xulang-org/packages/etcd`,由模块 github.com/xulang-org/packages 提供。

github.com/xulang-org/packages · 0.1.1 · 安装与使用

open

XuAPI
pub fn open(endpoint string) Client

用途

打开。

参数

endpoint string
endpoint(string)

返回

Client — 该类型的值

open_pool

XuAPI
pub fn open_pool(endpoint string, max_idle int) Pool

用途

打开pool。

参数

endpoint string
endpoint(string)
max_idle int
max_idle(int)

返回

Pool — 该类型的值

struct Response

XuAPI
pub struct Response {
    pub status_code int
    pub body string
}

用途

公开结构体 `Response`。

参数

status_code int
字段(int)
body string
正文

struct Client

XuAPI
pub struct Client {
    pub host string
    pub port int
}

用途

公开结构体 `Client`。

参数

host string
主机
port int
端口

new_client

XuAPI
pub fn new_client(endpoint string) Client

用途

构造 client。

参数

endpoint string
endpoint(string)

返回

Client — 该类型的值

(&mut Client) request

XuAPI
pub fn (c &mut Client) request(path string, body_json string) Response

用途

`&mut Client` 上的方法:请求。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
path string
文件系统路径(string)
body_json string
body_json(string)

返回

Response — 该类型的值

(&mut Client) put

XuAPI
pub fn (c &mut Client) put(key string, value string) int

用途

在 `&mut Client` 上调用 `put`。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
key string
键(string)
value string
value(string)

返回

int — 该类型的值

(&mut Client) put_with_lease

XuAPI
pub fn (c &mut Client) put_with_lease(key string, value string, lease_id int) int

用途

`&mut Client` 上的方法:putwithlease。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
key string
键(string)
value string
value(string)
lease_id int
lease_id(int)

返回

int — 该类型的值

(&mut Client) get

XuAPI
pub fn (c &mut Client) get(key string) string

用途

在 `&mut Client` 上调用 `get`。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
key string
键(string)

返回

string — 结果字符串

(&mut Client) exists

XuAPI
pub fn (c &mut Client) exists(key string) bool

用途

在 `&mut Client` 上调用 `exists`。

参数

c &mut Client
接收者 &mut Client(可变借用)
key string
键(string)

返回

bool — 是否成立

(&mut Client) delete

XuAPI
pub fn (c &mut Client) delete(key string) int

用途

`&mut Client` 上的方法:删除。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
key string
键(string)

返回

int — 该类型的值

(&mut Client) lease_grant

XuAPI
pub fn (c &mut Client) lease_grant(ttl_seconds int) int

用途

`&mut Client` 上的方法:leasegrant。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
ttl_seconds int
ttl_seconds(int)

返回

int — 该类型的值

(&mut Client) lease_revoke

XuAPI
pub fn (c &mut Client) lease_revoke(lease_id int) int

用途

`&mut Client` 上的方法:leaserevoke。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
lease_id int
lease_id(int)

返回

int — 该类型的值

(&mut Client) lease_keepalive

XuAPI
pub fn (c &mut Client) lease_keepalive(lease_id int) int

用途

`&mut Client` 上的方法:leasekeepalive。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
lease_id int
lease_id(int)

返回

int — 该类型的值

struct Pool

XuAPI
pub struct Pool {
    pub host string
    pub port int
    pub endpoint string
    pub state chan pool.State
    pub max_idle int
}

用途

公开结构体 `Pool`。

参数

host string
主机
port int
端口
endpoint string
字段(string)
state chan pool.State
字段(通道;类型 chan pool.State)
max_idle int
字段(int)

new_pool

XuAPI
pub fn new_pool(endpoint string, max_idle int) Pool

用途

构造 pool。

参数

endpoint string
endpoint(string)
max_idle int
max_idle(int)

返回

Pool — 该类型的值

(&Pool) get

XuAPI
pub fn (p &Pool) get() Client

用途

在 `&Pool` 上调用 `get`。

参数

p &Pool
接收者 &Pool(借用)

返回

Client — 该类型的值

(&Pool) dup

XuAPI
pub fn (p &Pool) dup() Pool

用途

在 `&Pool` 上调用 `dup`。

参数

p &Pool
接收者 &Pool(借用)

返回

Pool — 该类型的值

(&Pool) get_conn

XuAPI
pub fn (p &Pool) get_conn() int

用途

`&Pool` 上的方法:读取 conn。

参数

p &Pool
接收者 &Pool(借用)

返回

int — 该类型的值

(&Pool) put_conn

XuAPI
pub fn (p &Pool) put_conn(fd int)

用途

`&Pool` 上的方法:put连接。

参数

p &Pool
接收者 &Pool(借用)
fd int
文件描述符(int)

(&Pool) discard_conn

XuAPI
pub fn (p &Pool) discard_conn(fd int)

用途

`&Pool` 上的方法:丢弃连接。

参数

p &Pool
接收者 &Pool(借用)
fd int
文件描述符(int)

(&Pool) put

XuAPI
pub fn (p &Pool) put(key string, value string) int

用途

在 `&Pool` 上调用 `put`。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
key string
键(string)
value string
value(string)

返回

int — 该类型的值

(&Pool) get_key

XuAPI
pub fn (p &Pool) get_key(key string) string

用途

`&Pool` 上的方法:读取 key。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
key string
键(string)

返回

string — 结果字符串

(&Pool) delete

XuAPI
pub fn (p &Pool) delete(key string) int

用途

`&Pool` 上的方法:删除。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
key string
键(string)

返回

int — 该类型的值

(&Pool) exists

XuAPI
pub fn (p &Pool) exists(key string) bool

用途

在 `&Pool` 上调用 `exists`。

参数

p &Pool
接收者 &Pool(借用)
key string
键(string)

返回

bool — 是否成立

(&Pool) close

XuAPI
pub fn (p &Pool) close()

用途

`&Pool` 上的方法:关闭资源。

参数

p &Pool
接收者 &Pool(借用)