XU XUv0.8.8
EN

API

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

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

counts: 19 函数, 8 方法, 5 类型, 20 常量, 0 方法集

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

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

struct Response

XuAPI
pub struct Response {
    pub status int
    pub message string
    pub payload string
}

用途

公开结构体 `Response`。

参数

status int
字段(int)
message string
字段(string)
payload string
字段(string)

struct GrpcClient

XuAPI
pub struct GrpcClient {
    pub host string
    pub port int
}

用途

公开结构体 `GrpcClient`。

参数

host string
主机
port int
端口

new_client

XuAPI
pub fn new_client(endpoint string) GrpcClient

用途

构造 client。

参数

endpoint string
endpoint(string)

返回

GrpcClient — 该类型的值

(GrpcClient) read_h2_frame

XuAPI
pub fn (c GrpcClient) read_h2_frame(fd int) H2Frame

用途

`GrpcClient` 上的方法:读取h2frame。失败时 throw。

参数

c GrpcClient
接收者 GrpcClient(值接收者)
fd int
文件描述符(int)

返回

H2Frame — 该类型的值

(GrpcClient) connect

XuAPI
pub fn (c GrpcClient) connect() int

用途

在 `GrpcClient` 上调用 `connect`。失败时 throw。

参数

c GrpcClient
接收者 GrpcClient(值接收者)

返回

int — 该类型的值

(GrpcClient) call_unary

XuAPI
pub fn (c GrpcClient) call_unary(path string, req_bytes string) Response

用途

`GrpcClient` 上的方法:callunary。失败时 throw。

参数

c GrpcClient
接收者 GrpcClient(值接收者)
path string
文件系统路径(string)
req_bytes string
req_bytes(string)

返回

Response — 该类型的值

(GrpcClient) call_unary_on_fd

XuAPI
pub fn (c GrpcClient) call_unary_on_fd(fd int, path string, req_bytes string, stream_id int) Response

用途

`GrpcClient` 上的方法:callunary于fd。失败时 throw。

参数

c GrpcClient
接收者 GrpcClient(值接收者)
fd int
文件描述符(int)
path string
文件系统路径(string)
req_bytes string
req_bytes(string)
stream_id int
stream_id(int)

返回

Response — 该类型的值

const h2_client_preface

XuAPI
pub const h2_client_preface = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"

用途

公开常量 `h2_client_preface`。 值为 `"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"`

参数

无

const frame_data

XuAPI
pub const frame_data = 0

用途

公开常量 `frame_data`。 值为 `0`

参数

无

const frame_headers

XuAPI
pub const frame_headers = 1

用途

公开常量 `frame_headers`。 值为 `1`

参数

无

const frame_priority

XuAPI
pub const frame_priority = 2

用途

公开常量 `frame_priority`。 值为 `2`

参数

无

const frame_rst_stream

XuAPI
pub const frame_rst_stream = 3

用途

公开常量 `frame_rst_stream`。 值为 `3`

参数

无

const frame_settings

XuAPI
pub const frame_settings = 4

用途

公开常量 `frame_settings`。 值为 `4`

参数

无

const frame_push_promise

XuAPI
pub const frame_push_promise = 5

用途

公开常量 `frame_push_promise`。 值为 `5`

参数

无

const frame_ping

XuAPI
pub const frame_ping = 6

用途

公开常量 `frame_ping`。 值为 `6`

参数

无

const frame_goaway

XuAPI
pub const frame_goaway = 7

用途

公开常量 `frame_goaway`。 值为 `7`

参数

无

const frame_window_update

XuAPI
pub const frame_window_update = 8

用途

公开常量 `frame_window_update`。 值为 `8`

参数

无

const frame_continuation

XuAPI
pub const frame_continuation = 9

用途

公开常量 `frame_continuation`。 值为 `9`

参数

无

const flag_ack

XuAPI
pub const flag_ack = 1

用途

公开常量 `flag_ack`。 值为 `1`

参数

无

const flag_end_stream

XuAPI
pub const flag_end_stream = 1

用途

公开常量 `flag_end_stream`。 值为 `1`

参数

无

const flag_end_headers

XuAPI
pub const flag_end_headers = 4

用途

公开常量 `flag_end_headers`。 值为 `4`

参数

无

const flag_padded

XuAPI
pub const flag_padded = 8

用途

公开常量 `flag_padded`。 值为 `8`

参数

无

const flag_priority

XuAPI
pub const flag_priority = 32

用途

公开常量 `flag_priority`。 值为 `32`

参数

无

struct H2Frame

XuAPI
pub struct H2Frame {
    pub length int
    pub frame_type int
    pub flags int
    pub stream_id int
    pub payload string
}

用途

公开结构体 `H2Frame`。

参数

length int
字段(int)
frame_type int
字段(int)
flags int
字段(int)
stream_id int
字段(int)
payload string
字段(string)

encode_h2_header

XuAPI
pub fn encode_h2_header(len int, frame_type int, flags int, stream_id int) string

用途

编码。

参数

len int
len(int)
frame_type int
frame_type(int)
flags int
flags(int)
stream_id int
stream_id(int)

返回

string — 结果字符串

build_settings_frame

XuAPI
pub fn build_settings_frame(ack bool) string

用途

buildsettingsframe。

参数

ack bool
ack(bool)

返回

string — 结果字符串

build_data_frame

XuAPI
pub fn build_data_frame(stream_id int, data string, end_stream bool) string

用途

builddataframe。

参数

stream_id int
stream_id(int)
data string
数据(string)
end_stream bool
end_stream(bool)

返回

string — 结果字符串

build_grpc_hpack_headers

XuAPI
pub fn build_grpc_hpack_headers(path string) string

用途

buildgrpchpackheaders。

参数

path string
文件系统路径(string)

返回

string — 结果字符串

build_headers_frame

XuAPI
pub fn build_headers_frame(stream_id int, path string, end_stream bool) string

用途

buildheadersframe。

参数

stream_id int
stream_id(int)
path string
文件系统路径(string)
end_stream bool
end_stream(bool)

返回

string — 结果字符串

struct Pool

XuAPI
pub struct Pool {
    pub client GrpcClient
    pub idle chan int
    pub max_idle int
}

用途

公开结构体 `Pool`。

参数

client GrpcClient
字段(GrpcClient)
idle chan int
字段(通道;类型 chan int)
max_idle int
字段(int)

new_pool

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

用途

构造 pool。

参数

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

返回

Pool — 该类型的值

open_pool

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

用途

打开pool。

参数

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

返回

Pool — 该类型的值

(&Pool) get_conn

XuAPI
pub fn (p &Pool) get_conn() int

用途

`&Pool` 上的方法:读取 conn。

参数

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

返回

int — 该类型的值

(&Pool) put_conn

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

用途

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

参数

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

(&Pool) call_unary

XuAPI
pub fn (p &Pool) call_unary(path string, req_bytes string) Response

用途

`&Pool` 上的方法:callunary。失败时 throw。

参数

p &Pool
接收者 &Pool(借用)
path string
文件系统路径(string)
req_bytes string
req_bytes(string)

返回

Response — 该类型的值

(&Pool) close

XuAPI
pub fn (p &Pool) close()

用途

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

参数

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

const wire_varint

XuAPI
pub const wire_varint = 0

用途

公开常量 `wire_varint`。 值为 `0`

参数

无

const wire_fixed64

XuAPI
pub const wire_fixed64 = 1

用途

公开常量 `wire_fixed64`。 值为 `1`

参数

无

const wire_length_delimited

XuAPI
pub const wire_length_delimited = 2

用途

公开常量 `wire_length_delimited`。 值为 `2`

参数

无

const wire_fixed32

XuAPI
pub const wire_fixed32 = 5

用途

公开常量 `wire_fixed32`。 值为 `5`

参数

无

encode_varint

XuAPI
pub fn encode_varint(val int) string

用途

编码。

参数

val 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_full

XuAPI
pub fn decode_varint_full(buf &string, pos int) VarintResult

用途

解码。

参数

buf &string
缓冲(借用,调用方仍持有;类型 &string)
pos int
pos(int)

返回

VarintResult — 该类型的值

decode_varint

XuAPI
pub fn decode_varint(buf &string, pos int) int

用途

解码。

参数

buf &string
缓冲(借用,调用方仍持有;类型 &string)
pos int
pos(int)

返回

int — 该类型的值

encode_tag

XuAPI
pub fn encode_tag(field_num int, wire_type int) string

用途

编码。

参数

field_num int
field_num(int)
wire_type int
wire_type(int)

返回

string — 结果字符串

encode_string_field

XuAPI
pub fn encode_string_field(field_num int, val string) string

用途

编码。

参数

field_num int
field_num(int)
val string
值(string)

返回

string — 结果字符串

encode_int_field

XuAPI
pub fn encode_int_field(field_num int, val int) string

用途

编码。

参数

field_num int
field_num(int)
val int
值(int)

返回

string — 结果字符串

build_grpc_message

XuAPI
pub fn build_grpc_message(payload string) string

用途

buildgrpcmessage。

参数

payload string
payload(string)

返回

string — 结果字符串

parse_grpc_message

XuAPI
pub fn parse_grpc_message(raw string) string

用途

解析为 grpc message。

参数

raw string
raw(string)

返回

string — 结果字符串

decode_grpc_message

XuAPI
pub fn decode_grpc_message(raw string) string

用途

解码。失败时 throw。

参数

raw string
raw(string)

返回

string — 结果字符串

get_string_field

XuAPI
pub fn get_string_field(payload string, target_field int) string

用途

读取 string field。

参数

payload string
payload(string)
target_field int
target_field(int)

返回

string — 结果字符串

get_int_field

XuAPI
pub fn get_int_field(payload string, target_field int) int

用途

读取 int field。

参数

payload string
payload(string)
target_field int
target_field(int)

返回

int — 该类型的值