open
pub fn open(endpoint string) Client用途
打开。
参数
endpointstring- endpoint(string)
返回
Client — 该类型的值
API
#github.com/xulang-org/packages/consul扩展包 `consul #github.com/xulang-org/packages/consul`,由模块 github.com/xulang-org/packages 提供。
github.com/xulang-org/packages · 0.1.1 · 安装与使用
openpub fn open(endpoint string) Client打开。
endpoint stringClient — 该类型的值
open_authpub fn open_auth(endpoint string, token string) Client打开auth。
endpoint stringtoken stringClient — 该类型的值
(&mut Client) register_servicepub fn (c &mut Client) register_service(id string, name string, address string, port int) bool`&mut Client` 上的方法:registerservice。
c &mut Clientid stringname stringaddress stringport intbool — 是否成立
(&mut Client) deregister_servicepub fn (c &mut Client) deregister_service(id string) bool`&mut Client` 上的方法:deregisterservice。
c &mut Clientid stringbool — 是否成立
(&mut Client) get_servicepub fn (c &mut Client) get_service(name string) string`&mut Client` 上的方法:读取 service。失败时 throw。
c &mut Clientname stringstring — 结果字符串
struct Responsepub struct Response {
pub status_code int
pub body string
}公开结构体 `Response`。
status_code intbody stringstruct Clientpub struct Client {
pub host string
pub port int
pub token string
}公开结构体 `Client`。
host stringport inttoken stringnew_clientpub fn new_client(endpoint string, token string) Client构造 client。
endpoint stringtoken stringClient — 该类型的值
(&mut Client) requestpub fn (c &mut Client) request(method string, path string, body string) Response`&mut Client` 上的方法:请求。失败时 throw。
c &mut Clientmethod stringpath stringbody stringResponse — 该类型的值
(&mut Client) pingpub fn (c &mut Client) ping() bool在 `&mut Client` 上调用 `ping`。
c &mut Clientbool — 是否成立
(&mut Client) leaderpub fn (c &mut Client) leader() string在 `&mut Client` 上调用 `leader`。失败时 throw。
c &mut Clientstring — 结果字符串
(&mut Client) put_kvpub fn (c &mut Client) put_kv(key string, val string) bool`&mut Client` 上的方法:putkv。
c &mut Clientkey stringval stringbool — 是否成立
(&mut Client) get_kvpub fn (c &mut Client) get_kv(key string) string`&mut Client` 上的方法:读取 kv。失败时 throw。
c &mut Clientkey stringstring — 结果字符串
(&mut Client) delete_kvpub fn (c &mut Client) delete_kv(key string) bool`&mut Client` 上的方法:删除kv。
c &mut Clientkey stringbool — 是否成立
struct Poolpub struct Pool {
pub host string
pub port int
pub token string
pub state chan pool.State
pub max_idle int
}公开结构体 `Pool`。
host stringport inttoken stringstate chan pool.Statemax_idle intnew_poolpub fn new_pool(endpoint string, token string, max_idle int) Pool构造 pool。
endpoint stringtoken stringmax_idle intPool — 该类型的值
open_poolpub fn open_pool(endpoint string, token string, max_idle int) Pool打开pool。
endpoint stringtoken stringmax_idle intPool — 该类型的值
(&Pool) getpub fn (p &Pool) get() Client在 `&Pool` 上调用 `get`。
p &PoolClient — 该类型的值
(&Pool) duppub fn (p &Pool) dup() Pool在 `&Pool` 上调用 `dup`。
p &PoolPool — 该类型的值
(&Pool) get_connpub fn (p &Pool) get_conn() int`&Pool` 上的方法:读取 conn。
p &Poolint — 该类型的值
(&Pool) put_connpub fn (p &Pool) put_conn(fd int)`&Pool` 上的方法:put连接。
p &Poolfd int(&Pool) discard_connpub fn (p &Pool) discard_conn(fd int)`&Pool` 上的方法:丢弃连接。
p &Poolfd int(&Pool) put_kvpub fn (p &Pool) put_kv(key string, val string) bool`&Pool` 上的方法:putkv。
p &Poolkey stringval stringbool — 是否成立
(&Pool) get_kvpub fn (p &Pool) get_kv(key string) string`&Pool` 上的方法:读取 kv。失败时 throw。
p &Poolkey stringstring — 结果字符串
(&Pool) delete_kvpub fn (p &Pool) delete_kv(key string) bool`&Pool` 上的方法:删除kv。
p &Poolkey stringbool — 是否成立
(&Pool) register_servicepub fn (p &Pool) register_service(id string, name string, address string, port int) bool`&Pool` 上的方法:registerservice。
p &Poolid stringname stringaddress stringport intbool — 是否成立
(&Pool) deregister_servicepub fn (p &Pool) deregister_service(id string) bool`&Pool` 上的方法:deregisterservice。
p &Poolid stringbool — 是否成立
(&Pool) get_servicepub fn (p &Pool) get_service(name string) string`&Pool` 上的方法:读取 service。失败时 throw。
p &Poolname stringstring — 结果字符串
(&Pool) pingpub fn (p &Pool) ping() bool在 `&Pool` 上调用 `ping`。
p &Poolbool — 是否成立
(&Pool) closepub fn (p &Pool) close()`&Pool` 上的方法:关闭资源。
p &Pool