open
pub fn open(endpoint string) ClientPurpose
Public API convenience helpers for Consul driver
Parameters
endpointstring- endpoint (string)
Returns
Client — a value of this type
API
#github.com/xulang-org/packages/consulPublic API convenience helpers for Consul driver
github.com/xulang-org/packages · 0.1.1 · Install and use
openpub fn open(endpoint string) ClientPublic API convenience helpers for Consul driver
endpoint stringClient — a value of this type
open_authpub fn open_auth(endpoint string, token string) ClientOpen auth.
endpoint stringtoken stringClient — a value of this type
(&mut Client) register_servicepub fn (c &mut Client) register_service(id string, name string, address string, port int) boolMethod on `&mut Client`: register service.
c &mut Clientid stringname stringaddress stringport intbool — true or false
(&mut Client) deregister_servicepub fn (c &mut Client) deregister_service(id string) boolMethod on `&mut Client`: deregister service.
c &mut Clientid stringbool — true or false
(&mut Client) get_servicepub fn (c &mut Client) get_service(name string) stringMethod on `&mut Client`: read service. Throws on failure.
c &mut Clientname stringstring — result string
struct Responsepub struct Response {
pub status_code int
pub body string
}Public struct `Response`.
status_code intbody stringstruct Clientpub struct Client {
pub host string
pub port int
pub token string
}Public struct `Client`.
host stringport inttoken stringnew_clientpub fn new_client(endpoint string, token string) ClientConstruct client.
endpoint stringtoken stringClient — a value of this type
(&mut Client) requestpub fn (c &mut Client) request(method string, path string, body string) ResponseCall `request` on `&mut Client`. Throws on failure.
c &mut Clientmethod stringpath stringbody stringResponse — a value of this type
(&mut Client) pingpub fn (c &mut Client) ping() boolCall `ping` on `&mut Client`.
c &mut Clientbool — true or false
(&mut Client) leaderpub fn (c &mut Client) leader() stringCall `leader` on `&mut Client`. Throws on failure.
c &mut Clientstring — result string
(&mut Client) put_kvpub fn (c &mut Client) put_kv(key string, val string) boolMethod on `&mut Client`: put kv.
c &mut Clientkey stringval stringbool — true or false
(&mut Client) get_kvpub fn (c &mut Client) get_kv(key string) stringMethod on `&mut Client`: read kv. Throws on failure.
c &mut Clientkey stringstring — result string
(&mut Client) delete_kvpub fn (c &mut Client) delete_kv(key string) boolMethod on `&mut Client`: delete kv.
c &mut Clientkey stringbool — true or false
struct Poolpub struct Pool {
pub host string
pub port int
pub token string
pub state chan pool.State
pub max_idle int
}Connection Pool for HashiCorp Consul. Manages reusable TCP/HTTP socket connections.
host stringport inttoken stringstate chan pool.Statemax_idle intnew_poolpub fn new_pool(endpoint string, token string, max_idle int) PoolConstruct pool.
endpoint stringtoken stringmax_idle intPool — a value of this type
open_poolpub fn open_pool(endpoint string, token string, max_idle int) PoolOpen pool.
endpoint stringtoken stringmax_idle intPool — a value of this type
(&Pool) getpub fn (p &Pool) get() ClientCall `get` on `&Pool`.
p &PoolClient — a value of this type
(&Pool) duppub fn (p &Pool) dup() PoolShares sockets and close state; clones configuration strings.
p &PoolPool — a value of this type
(&Pool) get_connpub fn (p &Pool) get_conn() intMethod on `&Pool`: read conn.
p &Poolint — a value of this type
(&Pool) put_connpub fn (p &Pool) put_conn(fd int)Method on `&Pool`: put connection.
p &Poolfd int(&Pool) discard_connpub fn (p &Pool) discard_conn(fd int)Method on `&Pool`: discard connection.
p &Poolfd int(&Pool) put_kvpub fn (p &Pool) put_kv(key string, val string) boolMethod on `&Pool`: put kv.
p &Poolkey stringval stringbool — true or false
(&Pool) get_kvpub fn (p &Pool) get_kv(key string) stringMethod on `&Pool`: read kv. Throws on failure.
p &Poolkey stringstring — result string
(&Pool) delete_kvpub fn (p &Pool) delete_kv(key string) boolMethod on `&Pool`: delete kv.
p &Poolkey stringbool — true or false
(&Pool) register_servicepub fn (p &Pool) register_service(id string, name string, address string, port int) boolMethod on `&Pool`: register service.
p &Poolid stringname stringaddress stringport intbool — true or false
(&Pool) deregister_servicepub fn (p &Pool) deregister_service(id string) boolMethod on `&Pool`: deregister service.
p &Poolid stringbool — true or false
(&Pool) get_servicepub fn (p &Pool) get_service(name string) stringMethod on `&Pool`: read service. Throws on failure.
p &Poolname stringstring — result string
(&Pool) pingpub fn (p &Pool) ping() boolCall `ping` on `&Pool`.
p &Poolbool — true or false
(&Pool) closepub fn (p &Pool) close()Method on `&Pool`: close the resource.
p &Pool