XU XUv0.8.8
中文

API

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

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

counts: 5 fns, 22 methods, 3 types, 0 consts, 0 ifaces

Public API convenience helpers for Consul driver

github.com/xulang-org/packages · 0.1.1 · Install and use

open

XuAPI
pub fn open(endpoint string) Client

Purpose

Public API convenience helpers for Consul driver

Parameters

endpoint string
endpoint (string)

Returns

Client — a value of this type

open_auth

XuAPI
pub fn open_auth(endpoint string, token string) Client

Purpose

Open auth.

Parameters

endpoint string
endpoint (string)
token string
token (string)

Returns

Client — a value of this type

(&mut Client) register_service

XuAPI
pub fn (c &mut Client) register_service(id string, name string, address string, port int) bool

Purpose

Method on `&mut Client`: register service.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
id string
id (string)
name string
name (string)
address string
address (string)
port int
port (int)

Returns

bool — true or false

(&mut Client) deregister_service

XuAPI
pub fn (c &mut Client) deregister_service(id string) bool

Purpose

Method on `&mut Client`: deregister service.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
id string
id (string)

Returns

bool — true or false

(&mut Client) get_service

XuAPI
pub fn (c &mut Client) get_service(name string) string

Purpose

Method on `&mut Client`: read service. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
name string
name (string)

Returns

string — result string

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
}

Purpose

Public struct `Client`.

Parameters

host string
host
port int
port
token string
field (string)

new_client

XuAPI
pub fn new_client(endpoint string, token string) Client

Purpose

Construct client.

Parameters

endpoint string
endpoint (string)
token string
token (string)

Returns

Client — a value of this type

(&mut Client) request

XuAPI
pub fn (c &mut Client) request(method string, path string, body 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)

Returns

Response — a value of this type

(&mut Client) ping

XuAPI
pub fn (c &mut Client) ping() bool

Purpose

Call `ping` on `&mut Client`.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)

Returns

bool — true or false

(&mut Client) leader

XuAPI
pub fn (c &mut Client) leader() string

Purpose

Call `leader` on `&mut Client`. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)

Returns

string — result string

(&mut Client) put_kv

XuAPI
pub fn (c &mut Client) put_kv(key string, val string) bool

Purpose

Method on `&mut Client`: put kv.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
key string
key (string)
val string
value (string)

Returns

bool — true or false

(&mut Client) get_kv

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

Purpose

Method on `&mut Client`: read kv. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
key string
key (string)

Returns

string — result string

(&mut Client) delete_kv

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

Purpose

Method on `&mut Client`: delete kv.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
key string
key (string)

Returns

bool — true or false

struct Pool

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

Purpose

Connection Pool for HashiCorp Consul. Manages reusable TCP/HTTP socket connections.

Parameters

host string
host
port int
port
token 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, max_idle int) Pool

Purpose

Construct pool.

Parameters

endpoint string
endpoint (string)
token string
token (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, max_idle int) Pool

Purpose

Open pool.

Parameters

endpoint string
endpoint (string)
token string
token (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) put_kv

XuAPI
pub fn (p &Pool) put_kv(key string, val string) bool

Purpose

Method on `&Pool`: put kv.

Parameters

p &Pool
receiver &Pool (borrow)
key string
key (string)
val string
value (string)

Returns

bool — true or false

(&Pool) get_kv

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

Purpose

Method on `&Pool`: read kv. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
key string
key (string)

Returns

string — result string

(&Pool) delete_kv

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

Purpose

Method on `&Pool`: delete kv.

Parameters

p &Pool
receiver &Pool (borrow)
key string
key (string)

Returns

bool — true or false

(&Pool) register_service

XuAPI
pub fn (p &Pool) register_service(id string, name string, address string, port int) bool

Purpose

Method on `&Pool`: register service.

Parameters

p &Pool
receiver &Pool (borrow)
id string
id (string)
name string
name (string)
address string
address (string)
port int
port (int)

Returns

bool — true or false

(&Pool) deregister_service

XuAPI
pub fn (p &Pool) deregister_service(id string) bool

Purpose

Method on `&Pool`: deregister service.

Parameters

p &Pool
receiver &Pool (borrow)
id string
id (string)

Returns

bool — true or false

(&Pool) get_service

XuAPI
pub fn (p &Pool) get_service(name string) string

Purpose

Method on `&Pool`: read service. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
name string
name (string)

Returns

string — result string

(&Pool) ping

XuAPI
pub fn (p &Pool) ping() bool

Purpose

Call `ping` on `&Pool`.

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)