XU XUv0.8.8
中文

API

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

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

counts: 3 fns, 18 methods, 3 types, 0 consts, 0 ifaces

Alibaba Nacos Service Registration and Dynamic Configuration Client for Xu Supports OpenAPI v1/v2 service registration, discovery, heartbeat, and config publishing.

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

struct Response

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

Purpose

Public struct `Response`.

Parameters

status_code int
field (int)
headers string
field (string)
body string
body

struct Client

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

Purpose

Public struct `Client`.

Parameters

host string
host
port int
port
namespace_id string
field (string)

new_client

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

Purpose

Construct client.

Parameters

endpoint string
endpoint (string)
namespace string
namespace (string)

Returns

Client — a value of this type

(Client) request

XuAPI
pub fn (c Client) request(method string, path string, body string) Response

Purpose

Call `request` on `Client`. Throws on failure.

Parameters

c Client
receiver Client (value receiver)
method string
method (string)
path string
filesystem path (string)
body string
body (string)

Returns

Response — a value of this type

(Client) publish_config

XuAPI
pub fn (c Client) publish_config(data_id string, group string, content string) bool

Purpose

Method on `Client`: publish config.

Parameters

c Client
receiver Client (value receiver)
data_id string
data_id (string)
group string
group (string)
content string
content (string)

Returns

bool — true or false

(Client) get_config

XuAPI
pub fn (c Client) get_config(data_id string, group string) string

Purpose

Method on `Client`: read config. Throws on failure.

Parameters

c Client
receiver Client (value receiver)
data_id string
data_id (string)
group string
group (string)

Returns

string — result string

(Client) remove_config

XuAPI
pub fn (c Client) remove_config(data_id string, group string) bool

Purpose

Method on `Client`: remove config.

Parameters

c Client
receiver Client (value receiver)
data_id string
data_id (string)
group string
group (string)

Returns

bool — true or false

(Client) register_instance

XuAPI
pub fn (c Client) register_instance(service string, ip string, port int, group string) bool

Purpose

Method on `Client`: register instance.

Parameters

c Client
receiver Client (value receiver)
service string
service (string)
ip string
ip (string)
port int
port (int)
group string
group (string)

Returns

bool — true or false

(Client) get_instances

XuAPI
pub fn (c Client) get_instances(service string, group string) string

Purpose

Method on `Client`: read instances. Throws on failure.

Parameters

c Client
receiver Client (value receiver)
service string
service (string)
group string
group (string)

Returns

string — result string

(Client) deregister_instance

XuAPI
pub fn (c Client) deregister_instance(service string, ip string, port int, group string) bool

Purpose

Method on `Client`: deregister instance.

Parameters

c Client
receiver Client (value receiver)
service string
service (string)
ip string
ip (string)
port int
port (int)
group string
group (string)

Returns

bool — true or false

struct Pool

XuAPI
pub struct Pool {
    pub client Client
    pub state chan pool.State
    pub max_idle int
}

Purpose

Public struct `Pool`.

Parameters

client Client
field (Client)
state chan pool.State
field (channel; type chan pool.State)
max_idle int
field (int)

new_pool

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

Purpose

Construct pool.

Parameters

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

Returns

Pool — a value of this type

open_pool

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

Purpose

Open pool.

Parameters

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

Returns

Pool — 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) register_instance

XuAPI
pub fn (p &Pool) register_instance(service string, ip string, port int, group string) bool

Purpose

Method on `&Pool`: register instance.

Parameters

p &Pool
receiver &Pool (borrow)
service string
service (string)
ip string
ip (string)
port int
port (int)
group string
group (string)

Returns

bool — true or false

(&Pool) get_instances

XuAPI
pub fn (p &Pool) get_instances(service string, group string) string

Purpose

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

Parameters

p &Pool
receiver &Pool (borrow)
service string
service (string)
group string
group (string)

Returns

string — result string

(&Pool) deregister_instance

XuAPI
pub fn (p &Pool) deregister_instance(service string, ip string, port int, group string) bool

Purpose

Method on `&Pool`: deregister instance.

Parameters

p &Pool
receiver &Pool (borrow)
service string
service (string)
ip string
ip (string)
port int
port (int)
group string
group (string)

Returns

bool — true or false

(&Pool) publish_config

XuAPI
pub fn (p &Pool) publish_config(data_id string, group string, content string) bool

Purpose

Method on `&Pool`: publish config.

Parameters

p &Pool
receiver &Pool (borrow)
data_id string
data_id (string)
group string
group (string)
content string
content (string)

Returns

bool — true or false

(&Pool) get_config

XuAPI
pub fn (p &Pool) get_config(data_id string, group string) string

Purpose

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

Parameters

p &Pool
receiver &Pool (borrow)
data_id string
data_id (string)
group string
group (string)

Returns

string — result string

(&Pool) remove_config

XuAPI
pub fn (p &Pool) remove_config(data_id string, group string) bool

Purpose

Method on `&Pool`: remove config.

Parameters

p &Pool
receiver &Pool (borrow)
data_id string
data_id (string)
group string
group (string)

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)