API
#github.com/xulang-org/packages/rabbitmq
Xu 0.8.8 API
import: rabbitmq #github.com/xulang-org/packages/rabbitmq
counts: 18 fns, 20 methods, 4 types, 10 consts, 0 ifaces
Public API convenience helpers for RabbitMQ driver
github.com/xulang-org/packages · 0.1.1 · Install and use
open
pub fn open(host string, port int, user string, password string, vhost string) Client
Purpose
Public API convenience helpers for RabbitMQ driver
Parameters
host string- host (string)
port int- port (int)
user string- user (string)
password string- password (string)
vhost string- vhost (string)
Returns
Client — a value of this type
open_default
pub fn open_default() Client
Purpose
Open default.
Parameters
none
Returns
Client — a value of this type
struct Message
pub struct Message {
pub exchange string
pub routing_key string
pub body string
pub message_count int
}
Purpose
Public struct `Message`.
Parameters
exchange string- field (string)
routing_key string- field (string)
body string- body
message_count int- field (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
}
Purpose
Public struct `Client`.
Parameters
fd int- file descriptor
host string- host
port int- port
user string- field (string)
password string- field (string)
vhost string- field (string)
channel_id int- field (int)
(&mut Client) write_exact
pub fn (c &mut Client) write_exact(data string) int
Purpose
Method on `&mut Client`: write exact. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
data string- data (string)
Returns
int — a value of this type
(&mut Client) read_exact
pub fn (c &mut Client) read_exact(n int) string
Purpose
Method on `&mut Client`: read exact. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
n int- count, length, or limit (int)
Returns
string — result string
(&mut Client) send_frame
pub fn (c &mut Client) send_frame(frame_type int, channel int, payload string) int
Purpose
Method on `&mut Client`: send frame.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
frame_type int- frame_type (int)
channel int- channel (int)
payload string- payload (string)
Returns
int — a value of this type
(&mut Client) read_frame
pub fn (c &mut Client) read_frame() Frame
Purpose
Method on `&mut Client`: read frame. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
Frame — a value of this type
connect
pub fn connect(host string, port int, user string, password string, vhost string) Client
Purpose
connect; returns Client. Throws on failure.
Parameters
host string- host (string)
port int- port (int)
user string- user (string)
password string- password (string)
vhost string- vhost (string)
Returns
Client — a value of this type
(&mut Client) declare_queue
pub fn (c &mut Client) declare_queue(queue_name string, durable bool) int
Purpose
Method on `&mut Client`: declare queue. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
queue_name string- queue_name (string)
durable bool- durable (bool)
Returns
int — a value of this type
(&mut Client) declare_exchange
pub fn (c &mut Client) declare_exchange(exchange_name string, exchange_type string, durable bool) int
Purpose
Method on `&mut Client`: declare exchange. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
exchange_name string- exchange_name (string)
exchange_type string- exchange_type (string)
durable bool- durable (bool)
Returns
int — a value of this type
(&mut Client) bind_queue
pub fn (c &mut Client) bind_queue(queue_name string, exchange_name string, routing_key string) int
Purpose
Method on `&mut Client`: bind queue. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
queue_name string- queue_name (string)
exchange_name string- exchange_name (string)
routing_key string- routing_key (string)
Returns
int — a value of this type
(&mut Client) publish
pub fn (c &mut Client) publish(exchange_name string, routing_key string, message_body string) int
Purpose
Call `publish` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
exchange_name string- exchange_name (string)
routing_key string- routing_key (string)
message_body string- message_body (string)
Returns
int — a value of this type
(&mut Client) get
pub fn (c &mut Client) get(queue_name string, auto_ack bool) string
Purpose
Call `get` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
queue_name string- queue_name (string)
auto_ack bool- auto_ack (bool)
Returns
string — result string
(&mut Client) ping
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) close
pub fn (c &mut Client) close()
Purpose
Method on `&mut Client`: close the resource.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
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
}
Purpose
Connection Pool for RabbitMQ AMQP 0-9-1. Manages reusable TCP client connections and channels via scalar channel.
Parameters
host string- host
port int- port
user string- field (string)
password string- field (string)
vhost string- field (string)
idle chan int- field (channel; type chan int)
max_idle int- field (int)
new_pool
pub fn new_pool(host string, port int, user string, password string, vhost string, max_idle int) Pool
Purpose
Construct pool.
Parameters
host string- host (string)
port int- port (int)
user string- user (string)
password string- password (string)
vhost string- vhost (string)
max_idle int- max_idle (int)
Returns
Pool — a value of this type
open_pool
pub fn open_pool(host string, port int, user string, password string, vhost string, max_idle int) Pool
Purpose
Open pool.
Parameters
host string- host (string)
port int- port (int)
user string- user (string)
password string- password (string)
vhost string- vhost (string)
max_idle int- max_idle (int)
Returns
Pool — a value of this type
(&Pool) get
pub fn (p &Pool) get() Client
Purpose
Call `get` on `&Pool`. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
Returns
Client — a value of this type
(&Pool) get_conn
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
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) put
pub fn (p &Pool) put(c Client)
Purpose
Call `put` on `&Pool`.
Parameters
p &Pool- receiver &Pool (borrow)
c Client- byte or character code (Client)
(&Pool) declare_queue
pub fn (p &Pool) declare_queue(queue_name string, durable bool) int
Purpose
Method on `&Pool`: declare queue. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
queue_name string- queue_name (string)
durable bool- durable (bool)
Returns
int — a value of this type
(&Pool) publish
pub fn (p &Pool) publish(exchange_name string, routing_key string, body string) int
Purpose
Call `publish` on `&Pool`. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
exchange_name string- exchange_name (string)
routing_key string- routing_key (string)
body string- body (string)
Returns
int — a value of this type
(&Pool) get_message
pub fn (p &Pool) get_message(queue_name string, auto_ack bool) string
Purpose
Method on `&Pool`: read message. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
queue_name string- queue_name (string)
auto_ack bool- auto_ack (bool)
Returns
string — result string
(&Pool) ping
pub fn (p &Pool) ping() bool
Purpose
Call `ping` on `&Pool`.
Parameters
p &Pool- receiver &Pool (borrow)
Returns
bool — true or false
(&Pool) close
Purpose
Method on `&Pool`: close the resource.
Parameters
p &Pool- receiver &Pool (borrow)
const frame_method
pub const frame_method = 1
Purpose
AMQP 0-9-1 Protocol Constants Value `1`.
Parameters
none
const frame_body
Purpose
Public constant `frame_body`. Value `3`.
Parameters
none
const frame_heartbeat
pub const frame_heartbeat = 8
Purpose
Public constant `frame_heartbeat`. Value `8`.
Parameters
none
const frame_end
pub const frame_end = 206
Purpose
Public constant `frame_end`. Value `206`.
Parameters
none
const class_connection
pub const class_connection = 10
Purpose
Class IDs Value `10`.
Parameters
none
const class_channel
pub const class_channel = 20
Purpose
Public constant `class_channel`. Value `20`.
Parameters
none
const class_exchange
pub const class_exchange = 40
Purpose
Public constant `class_exchange`. Value `40`.
Parameters
none
const class_queue
pub const class_queue = 50
Purpose
Public constant `class_queue`. Value `50`.
Parameters
none
const class_basic
pub const class_basic = 60
Purpose
Public constant `class_basic`. Value `60`.
Parameters
none
struct Frame
pub struct Frame {
pub frame_type int
pub channel int
pub payload string
}
Purpose
Frame structure
Parameters
frame_type int- field (int)
channel int- field (int)
payload string- field (string)
encode_i8
pub fn encode_i8(v int) string
Purpose
Encode.
Parameters
v int- value (int)
Returns
string — result string
encode_i16
pub fn encode_i16(v int) string
Purpose
Encode.
Parameters
v int- value (int)
Returns
string — result string
encode_i32
pub fn encode_i32(v int) string
Purpose
Encode.
Parameters
v int- value (int)
Returns
string — result string
encode_i64
pub fn encode_i64(v int) string
Purpose
Encode.
Parameters
v int- value (int)
Returns
string — result string
decode_i8
pub fn decode_i8(s string, off int) int
Purpose
Decode.
Parameters
s string- source string (string)
off int- offset (int)
Returns
int — a value of this type
decode_i16
pub fn decode_i16(s string, off int) int
Purpose
Decode.
Parameters
s string- source string (string)
off int- offset (int)
Returns
int — a value of this type
decode_i32
pub fn decode_i32(s string, off int) int
Purpose
Decode.
Parameters
s string- source string (string)
off int- offset (int)
Returns
int — a value of this type
decode_i64
pub fn decode_i64(s string, off int) int
Purpose
Decode.
Parameters
s string- source string (string)
off int- offset (int)
Returns
int — a value of this type
encode_shortstr
pub fn encode_shortstr(s string) string
Purpose
Short string: 1-byte length prefix (0-255) + content
Parameters
s string- source string (string)
Returns
string — result string
encode_longstr
pub fn encode_longstr(s string) string
Purpose
Long string: 4-byte length prefix + content
Parameters
s string- source string (string)
Returns
string — result string
encode_empty_table
pub fn encode_empty_table() string
Purpose
Empty AMQP field table (4 bytes = 0 length)
Parameters
none
Returns
string — result string
build_frame
pub fn build_frame(frame_type int, channel int, payload string) string
Purpose
Frame builder
Parameters
frame_type int- frame_type (int)
channel int- channel (int)
payload string- payload (string)
Returns
string — result string
build_method_payload
pub fn build_method_payload(class_id int, method_id int, arguments string) string
Purpose
Method payload builder: Class ID (2B) + Method ID (2B) + Arguments
Parameters
class_id int- class_id (int)
method_id int- method_id (int)
arguments string- arguments (string)
Returns
string — result string