API
#github.com/xulang-org/packages/rabbitmq
Xu 0.8.8 API
import: rabbitmq #github.com/xulang-org/packages/rabbitmq
counts: 18 函数, 20 方法, 4 类型, 10 常量, 0 方法集
扩展包 `rabbitmq #github.com/xulang-org/packages/rabbitmq`,由模块 github.com/xulang-org/packages 提供。
github.com/xulang-org/packages · 0.1.1 · 安装与使用
open
pub fn open(host string, port int, user string, password string, vhost string) Client
用途
打开。
参数
host string- 主机(string)
port int- 端口(int)
user string- user(string)
password string- password(string)
vhost string- vhost(string)
返回
Client — 该类型的值
open_default
pub fn open_default() Client
用途
打开default。
参数
无
返回
Client — 该类型的值
struct Message
pub struct Message {
pub exchange string
pub routing_key string
pub body string
pub message_count int
}
用途
公开结构体 `Message`。
参数
exchange string- 字段(string)
routing_key string- 字段(string)
body string- 正文
message_count int- 字段(int)
struct Client
pub struct Client {
pub fd int
pub host string
pub port int
pub user string
pub password string
pub vhost string
pub channel_id int
}
用途
公开结构体 `Client`。
参数
fd int- 文件描述符
host string- 主机
port int- 端口
user string- 字段(string)
password string- 字段(string)
vhost string- 字段(string)
channel_id int- 字段(int)
(&mut Client) write_exact
pub fn (c &mut Client) write_exact(data string) int
用途
`&mut Client` 上的方法:写入exact。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
data string- 数据(string)
返回
int — 该类型的值
(&mut Client) read_exact
pub fn (c &mut Client) read_exact(n int) string
用途
`&mut Client` 上的方法:读取exact。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
n int- 数量、长度或上限(int)
返回
string — 结果字符串
(&mut Client) send_frame
pub fn (c &mut Client) send_frame(frame_type int, channel int, payload string) int
用途
`&mut Client` 上的方法:sendframe。
参数
c &mut Client- 接收者 &mut Client(可变借用)
frame_type int- frame_type(int)
channel int- channel(int)
payload string- payload(string)
返回
int — 该类型的值
(&mut Client) read_frame
pub fn (c &mut Client) read_frame() Frame
用途
`&mut Client` 上的方法:读取frame。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
返回
Frame — 该类型的值
connect
pub fn connect(host string, port int, user string, password string, vhost string) Client
用途
connect,返回 Client。失败时 throw。
参数
host string- 主机(string)
port int- 端口(int)
user string- user(string)
password string- password(string)
vhost string- vhost(string)
返回
Client — 该类型的值
(&mut Client) declare_queue
pub fn (c &mut Client) declare_queue(queue_name string, durable bool) int
用途
`&mut Client` 上的方法:declarequeue。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
queue_name string- queue_name(string)
durable bool- durable(bool)
返回
int — 该类型的值
(&mut Client) declare_exchange
pub fn (c &mut Client) declare_exchange(exchange_name string, exchange_type string, durable bool) int
用途
`&mut Client` 上的方法:declareexchange。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
exchange_name string- exchange_name(string)
exchange_type string- exchange_type(string)
durable bool- durable(bool)
返回
int — 该类型的值
(&mut Client) bind_queue
pub fn (c &mut Client) bind_queue(queue_name string, exchange_name string, routing_key string) int
用途
`&mut Client` 上的方法:bindqueue。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
queue_name string- queue_name(string)
exchange_name string- exchange_name(string)
routing_key string- routing_key(string)
返回
int — 该类型的值
(&mut Client) publish
pub fn (c &mut Client) publish(exchange_name string, routing_key string, message_body string) int
用途
在 `&mut Client` 上调用 `publish`。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
exchange_name string- exchange_name(string)
routing_key string- routing_key(string)
message_body string- message_body(string)
返回
int — 该类型的值
(&mut Client) get
pub fn (c &mut Client) get(queue_name string, auto_ack bool) string
用途
在 `&mut Client` 上调用 `get`。失败时 throw。
参数
c &mut Client- 接收者 &mut Client(可变借用)
queue_name string- queue_name(string)
auto_ack bool- auto_ack(bool)
返回
string — 结果字符串
(&mut Client) ping
pub fn (c &mut Client) ping() bool
用途
在 `&mut Client` 上调用 `ping`。
参数
c &mut Client- 接收者 &mut Client(可变借用)
返回
bool — 是否成立
(&mut Client) close
pub fn (c &mut Client) close()
用途
`&mut Client` 上的方法:关闭资源。
参数
c &mut Client- 接收者 &mut Client(可变借用)
struct Pool
pub struct Pool {
pub host string
pub port int
pub user string
pub password string
pub vhost string
pub idle chan int
pub max_idle int
}
用途
公开结构体 `Pool`。
参数
host string- 主机
port int- 端口
user string- 字段(string)
password string- 字段(string)
vhost string- 字段(string)
idle chan int- 字段(通道;类型 chan int)
max_idle int- 字段(int)
new_pool
pub fn new_pool(host string, port int, user string, password string, vhost string, max_idle int) Pool
用途
构造 pool。
参数
host string- 主机(string)
port int- 端口(int)
user string- user(string)
password string- password(string)
vhost string- vhost(string)
max_idle int- max_idle(int)
返回
Pool — 该类型的值
open_pool
pub fn open_pool(host string, port int, user string, password string, vhost string, max_idle int) Pool
用途
打开pool。
参数
host string- 主机(string)
port int- 端口(int)
user string- user(string)
password string- password(string)
vhost string- vhost(string)
max_idle int- max_idle(int)
返回
Pool — 该类型的值
(&Pool) get
pub fn (p &Pool) get() Client
用途
在 `&Pool` 上调用 `get`。失败时 throw。
参数
p &Pool- 接收者 &Pool(借用)
返回
Client — 该类型的值
(&Pool) get_conn
pub fn (p &Pool) get_conn() int
用途
`&Pool` 上的方法:读取 conn。
参数
p &Pool- 接收者 &Pool(借用)
返回
int — 该类型的值
(&Pool) put_conn
pub fn (p &Pool) put_conn(fd int)
用途
`&Pool` 上的方法:put连接。
参数
p &Pool- 接收者 &Pool(借用)
fd int- 文件描述符(int)
(&Pool) put
pub fn (p &Pool) put(c Client)
用途
在 `&Pool` 上调用 `put`。
参数
p &Pool- 接收者 &Pool(借用)
c Client- 字节或字符码(Client)
(&Pool) declare_queue
pub fn (p &Pool) declare_queue(queue_name string, durable bool) int
用途
`&Pool` 上的方法:declarequeue。失败时 throw。
参数
p &Pool- 接收者 &Pool(借用)
queue_name string- queue_name(string)
durable bool- durable(bool)
返回
int — 该类型的值
(&Pool) publish
pub fn (p &Pool) publish(exchange_name string, routing_key string, body string) int
用途
在 `&Pool` 上调用 `publish`。失败时 throw。
参数
p &Pool- 接收者 &Pool(借用)
exchange_name string- exchange_name(string)
routing_key string- routing_key(string)
body string- 正文(string)
返回
int — 该类型的值
(&Pool) get_message
pub fn (p &Pool) get_message(queue_name string, auto_ack bool) string
用途
`&Pool` 上的方法:读取 message。失败时 throw。
参数
p &Pool- 接收者 &Pool(借用)
queue_name string- queue_name(string)
auto_ack bool- auto_ack(bool)
返回
string — 结果字符串
(&Pool) ping
pub fn (p &Pool) ping() bool
用途
在 `&Pool` 上调用 `ping`。
参数
p &Pool- 接收者 &Pool(借用)
返回
bool — 是否成立
(&Pool) close
用途
`&Pool` 上的方法:关闭资源。
参数
p &Pool- 接收者 &Pool(借用)
const frame_method
pub const frame_method = 1
用途
公开常量 `frame_method`。 值为 `1`
参数
无
const frame_body
用途
公开常量 `frame_body`。 值为 `3`
参数
无
const frame_heartbeat
pub const frame_heartbeat = 8
用途
公开常量 `frame_heartbeat`。 值为 `8`
参数
无
const frame_end
pub const frame_end = 206
用途
公开常量 `frame_end`。 值为 `206`
参数
无
const class_connection
pub const class_connection = 10
用途
公开常量 `class_connection`。 值为 `10`
参数
无
const class_channel
pub const class_channel = 20
用途
公开常量 `class_channel`。 值为 `20`
参数
无
const class_exchange
pub const class_exchange = 40
用途
公开常量 `class_exchange`。 值为 `40`
参数
无
const class_queue
pub const class_queue = 50
用途
公开常量 `class_queue`。 值为 `50`
参数
无
const class_basic
pub const class_basic = 60
用途
公开常量 `class_basic`。 值为 `60`
参数
无
struct Frame
pub struct Frame {
pub frame_type int
pub channel int
pub payload string
}
用途
公开结构体 `Frame`。
参数
frame_type int- 字段(int)
channel int- 字段(int)
payload string- 字段(string)
encode_i8
pub fn encode_i8(v int) string
用途
编码。
参数
v int- 值(int)
返回
string — 结果字符串
encode_i16
pub fn encode_i16(v int) string
用途
编码。
参数
v int- 值(int)
返回
string — 结果字符串
encode_i32
pub fn encode_i32(v int) string
用途
编码。
参数
v int- 值(int)
返回
string — 结果字符串
encode_i64
pub fn encode_i64(v int) string
用途
编码。
参数
v int- 值(int)
返回
string — 结果字符串
decode_i8
pub fn decode_i8(s string, off int) int
用途
解码。
参数
s string- 源字符串(string)
off int- 偏移(int)
返回
int — 该类型的值
decode_i16
pub fn decode_i16(s string, off int) int
用途
解码。
参数
s string- 源字符串(string)
off int- 偏移(int)
返回
int — 该类型的值
decode_i32
pub fn decode_i32(s string, off int) int
用途
解码。
参数
s string- 源字符串(string)
off int- 偏移(int)
返回
int — 该类型的值
decode_i64
pub fn decode_i64(s string, off int) int
用途
解码。
参数
s string- 源字符串(string)
off int- 偏移(int)
返回
int — 该类型的值
encode_shortstr
pub fn encode_shortstr(s string) string
用途
编码。
参数
s string- 源字符串(string)
返回
string — 结果字符串
encode_longstr
pub fn encode_longstr(s string) string
用途
编码。
参数
s string- 源字符串(string)
返回
string — 结果字符串
encode_empty_table
pub fn encode_empty_table() string
用途
编码。
参数
无
返回
string — 结果字符串
build_frame
pub fn build_frame(frame_type int, channel int, payload string) string
用途
buildframe。
参数
frame_type int- frame_type(int)
channel int- channel(int)
payload string- payload(string)
返回
string — 结果字符串
build_method_payload
pub fn build_method_payload(class_id int, method_id int, arguments string) string
用途
buildmethodpayload。
参数
class_id int- class_id(int)
method_id int- method_id(int)
arguments string- arguments(string)
返回
string — 结果字符串