# Functions
AddDescriptor 添加描述符号表, 对于已经实现的协议则不允许修改.
CalcChecksum 经典校验和算法.
CalcSHA 计算一个字符串hash值的十六进制字符串, 若字符串为空,则直接返回.
CalcSHA1 计算字符串的SHA-1值.
CalcSHA256 计算字符串的SHA-256值.
CreateCrypto 设置加密方案
@param option string 加密方案, 支持token/no (令牌加密和不加密) @param key []string 其他加密参数.
DefaultCrypto 默认的加解密器,就是不加密.
FrameCombine 组合消息帧,将若干个消息,组合到一个帧内 在调用此方法之前需首先设置帧类型 TransferFrame.SetType 组合空消息帧无意义, 因此需自行保证 msgs 不为空.
FrameSplit 消息帧拆分,将消息帧内的数据解析提取为若干个消息 因此在调用此方法之前不得调用 TransferFrame.SetType.
No description provided by the author
No description provided by the author
IsMessageDefined 此消息是否可以被自由定义.
JsonMessageParseFrom 从reader解析消息,此操作不够优化,应考虑使用 parse 方法.
NewCounter 创建一个新的计数器.
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
已接受,正常状态.
No description provided by the author
No description provided by the author
消费者消息类别 s -> c CMessage.
No description provided by the author
0x3C (可见字符: <).
No description provided by the author
0x0D (回车符).
c -> s HeartbeatMessage.
No description provided by the author
No description provided by the author
生产者消息响应 s -> c MessageResponse.
No description provided by the author
如果增加了新的协议代码,都需要在 descriptors 中添加其类型.
生产者消息类别 c -> s PMessage.
No description provided by the author
No description provided by the author
s -> c MessageResponse.
客户端消费者/生产者注册消息类别 c -> s RegisterMessage.
令客户端重新发起注册流程, 无消息体.
密钥不正确.
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
CMessage 消费者消息记录, 不允许复制
消息结构: | TopicLen | Topic | KeyLen | key | ValueLen | Value | Offset | ProductTime | |--------------|-----------------|------------|-------------------|--------------|-----------|------------|-----------------| len | 1 | N [1-255] bytes | 1 | N [1-255] bytes | 2 | N | 8 | 8 | |--------------|-----------------|------------|-------------------|--------------|-----------|------------|-----------------|.
Counter 计数器.
No description provided by the author
No description provided by the author
No description provided by the author
HeartbeatMessage 心跳.
MessageResponse 消息响应, P和C通用.
No description provided by the author
NoCrypto 不加密.
No description provided by the author
PMessage 生产者消息数据, 不允许复制
消息结构: | TopicLen | Topic | KeyLen | key | ValueLen | Value | |--------------|-----------------|------------|-------------------|--------------|-----------| len | 1 | N [1-255] bytes | 1 | N [1-255] bytes | 2 | N | |--------------|-----------------|------------|-------------------|--------------|-----------|.
No description provided by the author
RegisterMessage 消息注册,适用于生产者和消费者.
TokenCrypto 基于Token的加解密器,用于加密注册消息 也可用于加密传输消息.
TransferFrame 传输协议帧
帧与底层的传输协议无关, 帧是包含了具体消息的增加了冗余校验等信息的数据报; 帧内部可以包含一条或多条相同类型的消息, 因此帧可一次性传输多条相同的消息; 帧的大小没有限制, 真正对帧大小有限制的是底层的传输层, 具体是 transfer.Transfer 的要求;
帧结构: | head | mType | dataSize | data | checksum | tail | |----------|----------|--------------|--------------------|--------------|----------| len | 1 | 1 | 2 | N bytes | 2 | 1 | |----------|----------|--------------|--------------------|--------------|----------| 取值 | 0x3C | | | | | 0x0D | |----------|----------|--------------|--------------------|--------------|----------|
# Usage:
将帧载荷解析成具体的协议: frame := TransferFrame{} frame.Unmarshal(X) X := frame.UnmarshalTo()
从消息构建帧: frame := TransferFrame{} frame.BuildWith(proto.MessageType, []byte{}) frame.BuildFrom(X).
# Type aliases
No description provided by the author
DecryptFunc 解密方法签名.
EncryptFunc 加密方法签名.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author