const DEFAULT_TIMEOUT_NS
pub const DEFAULT_TIMEOUT_NS = 30000000000用途
常量 DEFAULT_TIMEOUT_NS,定义了相关的协议或算法配置参数。
#github.com/xulang-org/packages/transport扩展包 `transport #github.com/xulang-org/packages/transport`,由模块 github.com/xulang-org/packages 提供。
github.com/xulang-org/packages · 1.0.2 · 安装与使用
const DEFAULT_TIMEOUT_NSpub const DEFAULT_TIMEOUT_NS = 30000000000常量 DEFAULT_TIMEOUT_NS,定义了相关的协议或算法配置参数。
const MAX_HEADER_BYTESpub const MAX_HEADER_BYTES = 1048576常量 MAX_HEADER_BYTES,定义了相关的协议或算法配置参数。
const MAX_MESSAGE_BYTESpub const MAX_MESSAGE_BYTES = 10485760常量 MAX_MESSAGE_BYTES,定义了相关的协议或算法配置参数。
struct Endpointpub struct Endpoint {
pub scheme string
pub host string
pub port int
pub path string
pub secure bool
}承载 scheme、host、port、path、secure 等属性的结构体。
scheme stringhost stringport intpath stringsecure boolstruct Connpub struct Conn {
pub fd int
pub tls_conn tls.Conn
pub secure bool
pub closed bool
pub eof bool
pub buf string
}承载 fd、tls_conn、secure、closed、eof 等属性的结构体。
fd inttls_conn tls.Connsecure boolclosed booleof boolbuf stringparse_endpointpub fn parse_endpoint(raw string, fallback_port int) Endpoint解析为 endpoint。失败时抛出错误,调用方需处理或继续传播。
raw stringfallback_port intEndpoint — 该类型的值
secure_endpointpub fn secure_endpoint(ep Endpoint) bool执行 secure endpoint 操作。
ep Endpointbool — 是否成立
dialpub fn dial(ep Endpoint, cfg tls.Config, timeout_ns int) Conn发起连接。失败时抛出错误,调用方需处理或继续传播。
ep Endpointcfg tls.Configtimeout_ns intConn — 该类型的值
from_fdpub fn from_fd(fd int) Conn从 fd 构造。失败时抛出错误,调用方需处理或继续传播。
fd intConn — 该类型的值
closed_connpub fn closed_conn() Conn执行 closed conn 操作。
无需传入参数。
Conn — 该类型的值
($&Conn) readpub fn (c $&Conn) read(max int) string$&Conn 上的操作:读出最多 max 字节。失败时抛出错误,调用方需处理或继续传播。
c $&ConnConn 实例;以独占借用传入,方法可修改它,调用方仍持有实例。max intstring — 结果字符串
($&Conn) writepub fn (c $&Conn) write(data &string) int$&Conn 上的操作:写入数据,返回写入的字节数。失败时抛出错误,调用方需处理或继续传播。
c $&ConnConn 实例;以独占借用传入,方法可修改它,调用方仍持有实例。data &stringint — 写入的字节数
($&Conn) write_allpub fn (c $&Conn) write_all(data string) int$&Conn 上的操作:执行 write all 操作。失败时抛出错误,调用方需处理或继续传播。
c $&ConnConn 实例;以独占借用传入,方法可修改它,调用方仍持有实例。data stringint — 该类型的值
($&Conn) closepub fn (c $&Conn) close() int$&Conn 上的操作:关闭资源。
c $&ConnConn 实例;以独占借用传入,方法可修改它,调用方仍持有实例。int — 该类型的值
request_rawpub fn request_raw(ep Endpoint, cfg tls.Config, request string, method string) http.Response执行 request raw 操作。失败时抛出错误,调用方需处理或继续传播。
ep Endpointcfg tls.Configrequest stringmethod stringhttp.Response — 该类型的值
read_responsepub fn read_response(c $&Conn, method string) http.Response读取响应。失败时抛出错误,调用方需处理或继续传播。
c $&Connmethod stringhttp.Response — 该类型的值