XU XUv0.8.8
EN

API

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

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

counts: 29 函数, 17 方法, 3 类型, 0 常量, 0 方法集

扩展包 `kafka #github.com/xulang-org/packages/kafka`,由模块 github.com/xulang-org/packages 提供。

github.com/xulang-org/packages · 0.1.1 · 安装与使用

open

XuAPI
pub fn open(broker string) Client

用途

打开。失败时 throw。

参数

broker string
broker(string)

返回

Client — 该类型的值

open_client

XuAPI
pub fn open_client(broker string, client_id string) Client

用途

打开客户端。失败时 throw。

参数

broker string
broker(string)
client_id string
client_id(string)

返回

Client — 该类型的值

open_pool_client

XuAPI
pub fn open_pool_client(broker string, client_id string, max_idle int) Pool

用途

打开pool客户端。

参数

broker string
broker(string)
client_id string
client_id(string)
max_idle int
max_idle(int)

返回

Pool — 该类型的值

struct Client

XuAPI
pub struct Client {
    pub fd int
    pub broker string
    pub client_id string
    pub next_correlation_id int
}

用途

公开结构体 `Client`。

参数

fd int
文件描述符
broker string
字段(string)
client_id string
字段(string)
next_correlation_id int
字段(int)

(&mut Client) write_exact

XuAPI
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

XuAPI
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) round_trip

XuAPI
pub fn (c &mut Client) round_trip(req_bytes string) string

用途

`&mut Client` 上的方法:舍入trip。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
req_bytes string
req_bytes(string)

返回

string — 结果字符串

connect

XuAPI
pub fn connect(broker string, client_id string) Client

用途

connect,返回 Client。失败时 throw。

参数

broker string
broker(string)
client_id string
client_id(string)

返回

Client — 该类型的值

(&mut Client) ping

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

用途

在 `&mut Client` 上调用 `ping`。

参数

c &mut Client
接收者 &mut Client(可变借用)

返回

bool — 是否成立

(&mut Client) metadata

XuAPI
pub fn (c &mut Client) metadata(topic string) bool

用途

在 `&mut Client` 上调用 `metadata`。

参数

c &mut Client
接收者 &mut Client(可变借用)
topic string
topic(string)

返回

bool — 是否成立

(&mut Client) produce

XuAPI
pub fn (c &mut Client) produce(topic string, partition int, message string) int

用途

在 `&mut Client` 上调用 `produce`。

参数

c &mut Client
接收者 &mut Client(可变借用)
topic string
topic(string)
partition int
partition(int)
message string
message(string)

返回

int — 该类型的值

(&mut Client) produce_key_value

XuAPI
pub fn (c &mut Client) produce_key_value(topic string, partition int, key string, val string) int

用途

`&mut Client` 上的方法:produce键值。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
topic string
topic(string)
partition int
partition(int)
key string
键(string)
val string
值(string)

返回

int — 该类型的值

(&mut Client) fetch

XuAPI
pub fn (c &mut Client) fetch(topic string, partition int, offset int) []string

用途

在 `&mut Client` 上调用 `fetch`。失败时 throw。

参数

c &mut Client
接收者 &mut Client(可变借用)
topic string
topic(string)
partition int
partition(int)
offset int
偏移(int)

返回

[]string — 切片结果

(&mut Client) close

XuAPI
pub fn (c &mut Client) close()

用途

`&mut Client` 上的方法:关闭资源。

参数

c &mut Client
接收者 &mut Client(可变借用)

struct Pool

XuAPI
pub struct Pool {
    pub broker string
    pub client_id string
    pub idle chan int
    pub max_idle int
}

用途

公开结构体 `Pool`。

参数

broker string
字段(string)
client_id string
字段(string)
idle chan int
字段(通道;类型 chan int)
max_idle int
字段(int)

new_pool

XuAPI
pub fn new_pool(broker string, client_id string, max_idle int) Pool

用途

构造 pool。

参数

broker string
broker(string)
client_id string
client_id(string)
max_idle int
max_idle(int)

返回

Pool — 该类型的值

open_pool

XuAPI
pub fn open_pool(broker string, client_id string, max_idle int) Pool

用途

打开pool。

参数

broker string
broker(string)
client_id string
client_id(string)
max_idle int
max_idle(int)

返回

Pool — 该类型的值

(&Pool) get

XuAPI
pub fn (p &Pool) get() Client

用途

在 `&Pool` 上调用 `get`。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)

返回

Client — 该类型的值

(&Pool) ping

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

用途

在 `&Pool` 上调用 `ping`。

参数

p &Pool
接收者 &Pool(借用)

返回

bool — 是否成立

(&Pool) produce

XuAPI
pub fn (p &Pool) produce(topic string, partition int, message string) int

用途

在 `&Pool` 上调用 `produce`。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
topic string
topic(string)
partition int
partition(int)
message string
message(string)

返回

int — 该类型的值

(&Pool) produce_key_value

XuAPI
pub fn (p &Pool) produce_key_value(topic string, partition int, key string, val string) int

用途

`&Pool` 上的方法:produce键值。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
topic string
topic(string)
partition int
partition(int)
key string
键(string)
val string
值(string)

返回

int — 该类型的值

(&Pool) fetch

XuAPI
pub fn (p &Pool) fetch(topic string, partition int, offset int) []string

用途

在 `&Pool` 上调用 `fetch`。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
topic string
topic(string)
partition int
partition(int)
offset int
偏移(int)

返回

[]string — 切片结果

(&Pool) put_conn

XuAPI
pub fn (p &Pool) put_conn(fd int)

用途

`&Pool` 上的方法:put连接。

参数

p &Pool
接收者 &Pool(借用)
fd int
文件描述符(int)

(&Pool) put

XuAPI
pub fn (p &Pool) put(c Client)

用途

在 `&Pool` 上调用 `put`。

参数

p &Pool
接收者 &Pool(借用)
c Client
字节或字符码(Client)

(&Pool) close

XuAPI
pub fn (p &Pool) close()

用途

`&Pool` 上的方法:关闭资源。

参数

p &Pool
接收者 &Pool(借用)

encode_i8

XuAPI
pub fn encode_i8(v int) string

用途

编码。

参数

v int
值(int)

返回

string — 结果字符串

encode_i16

XuAPI
pub fn encode_i16(v int) string

用途

编码。

参数

v int
值(int)

返回

string — 结果字符串

encode_i32

XuAPI
pub fn encode_i32(v int) string

用途

编码。

参数

v int
值(int)

返回

string — 结果字符串

encode_i64

XuAPI
pub fn encode_i64(v int) string

用途

编码。

参数

v int
值(int)

返回

string — 结果字符串

encode_string

XuAPI
pub fn encode_string(s string) string

用途

编码。

参数

s string
源字符串(string)

返回

string — 结果字符串

encode_null_string

XuAPI
pub fn encode_null_string() string

用途

编码。

参数

无

返回

string — 结果字符串

encode_bytes

XuAPI
pub fn encode_bytes(b string) string

用途

编码。

参数

b string
b(string)

返回

string — 结果字符串

encode_null_bytes

XuAPI
pub fn encode_null_bytes() string

用途

编码。

参数

无

返回

string — 结果字符串

encode_zigzag_i32

XuAPI
pub fn encode_zigzag_i32(n int) string

用途

编码。

参数

n int
数量、长度或上限(int)

返回

string — 结果字符串

encode_zigzag_i64

XuAPI
pub fn encode_zigzag_i64(n int) string

用途

编码。

参数

n int
数量、长度或上限(int)

返回

string — 结果字符串

struct VarintResult

XuAPI
pub struct VarintResult {
    pub value int
    pub bytes_read int
}

用途

公开结构体 `VarintResult`。

参数

value int
字段(int)
bytes_read int
字段(int)

decode_varint

XuAPI
pub fn decode_varint(s &string, off int) VarintResult

用途

解码。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)
off int
偏移(int)

返回

VarintResult — 该类型的值

decode_zigzag

XuAPI
pub fn decode_zigzag(s &string, off int) VarintResult

用途

解码。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)
off int
偏移(int)

返回

VarintResult — 该类型的值

decode_i16

XuAPI
pub fn decode_i16(s &string, off int) int

用途

解码。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)
off int
偏移(int)

返回

int — 该类型的值

decode_i32

XuAPI
pub fn decode_i32(s &string, off int) int

用途

解码。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)
off int
偏移(int)

返回

int — 该类型的值

decode_i64

XuAPI
pub fn decode_i64(s &string, off int) int

用途

解码。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)
off int
偏移(int)

返回

int — 该类型的值

build_request

XuAPI
pub fn build_request(api_key int, api_version int, correlation_id int, client_id string, body string) string

用途

build请求。

参数

api_key int
api_key(int)
api_version int
api_version(int)
correlation_id int
correlation_id(int)
client_id string
client_id(string)
body string
正文(string)

返回

string — 结果字符串

build_record_batch

XuAPI
pub fn build_record_batch(key string, val string) string

用途

buildrecordbatch。

参数

key string
键(string)
val string
值(string)

返回

string — 结果字符串

build_produce_request

XuAPI
pub fn build_produce_request(correlation_id int, client_id string, topic string, partition int, key string, val string) string

用途

buildproduce请求。

参数

correlation_id int
correlation_id(int)
client_id string
client_id(string)
topic string
topic(string)
partition int
partition(int)
key string
键(string)
val string
值(string)

返回

string — 结果字符串

build_fetch_request

XuAPI
pub fn build_fetch_request(correlation_id int, client_id string, topic string, partition int, offset int) string

用途

buildfetch请求。

参数

correlation_id int
correlation_id(int)
client_id string
client_id(string)
topic string
topic(string)
partition int
partition(int)
offset int
偏移(int)

返回

string — 结果字符串

build_metadata_request

XuAPI
pub fn build_metadata_request(correlation_id int, client_id string, topic string) string

用途

buildmetadata请求。

参数

correlation_id int
correlation_id(int)
client_id string
client_id(string)
topic string
topic(string)

返回

string — 结果字符串

build_apiversions_request

XuAPI
pub fn build_apiversions_request(correlation_id int, client_id string) string

用途

buildapiversions请求。

参数

correlation_id int
correlation_id(int)
client_id string
client_id(string)

返回

string — 结果字符串

parse_produce_response

XuAPI
pub fn parse_produce_response(resp string) int

用途

解析为 produce response。失败时 throw。

参数

resp string
resp(string)

返回

int — 该类型的值

parse_fetch_response

XuAPI
pub fn parse_fetch_response(resp string) []string

用途

解析为 fetch response。失败时 throw。

参数

resp string
resp(string)

返回

[]string — 切片结果