AMQP 1.0 typed wire codec and bounded sans-I/O messaging state machines
moon version --all
moon check --target all --deny-warn
moon build --target all --deny-warn
moon test --target all --deny-warn
moon run examples/tasks --target native --deny-warn
moon run examples/telemetry --target native --deny-warn
moon run examples/bridge --target js --deny-warn
moon run examples/scale --target native --deny-warn
moon fmt --check
moon info
git diff --exit-code.\tools\windows\moon.ps1 check --target all --deny-warn
.\tools\windows\moon.ps1 test --target all --deny-warn
.\tools\windows\moon.ps1 run examples/tasks --target native --deny-warnmoon add binhongcha/moonamqp1@0.1.0import { "binhongcha/moonamqp1" @amqp, }
pkgtype(kind: "executable")fn main raise {
let message = @amqp.Message::data(b"payload", properties=[
("sequence", ULong(18446744073709551615UL)),
("kind", Text("job")),
])
let bytes = @amqp.encode_message(message)
let restored = @amqp.decode_message(bytes)
assert_eq(restored.data_bytes(), b"payload")
}| 层次 | 支持 | 当前边界 |
|---|---|---|
| 值 | 全部原始域、十进制原始字节、精确整数/时间戳、list/map、typed array、数字或符号 descriptor | 十进制不提供算术;数组公共 constructor 最多一层 descriptor;编码采用全宽 canonical 形式 |
| 文本 | 严格 UTF-8、Unicode scalar、ASCII symbol,保留 BOM 和 ASCII NUL | 拒绝非法 UTF-8 与未配对 UTF-16 代理项,不静默替换 |
| 帧 | AMQP1.0 header、9 类 transport performative、扩展头、空 heartbeat、任意 feed 分块 | SASL frame/type、TLS header、未知额外 performative 字段明确拒绝 |
| 消息 | header、注解、properties、application-properties、data/sequence/value body、footer | 检查顺序、唯一性、互斥及字段域;未知 section 不静默跳过 |
| 状态 | 一个 connection、一个 session、多 link、本地/远端 channel 与 handle 独立映射 | 不支持 crossed begin、多 session、session/link 恢复、动态/持久 terminus、过滤及能力协商 |
| 收发 | link credit、session window、自动发送分片、接收组装/aborted、三种 sender settle mode、receiver first | 不支持 receiver second、drain、resume、事务、非零 message-format、分片中改变 settlement |
| 确认 | accepted、rejected(保留无 error 的拒绝)、released、modified 的两个布尔标志、范围 disposition | received/事务状态、modified 附加注解明确不支持;确认不等同业务 exactly-once |
| 宿主 | bytes/commands → bytes/events;原生 CLI 文件及 stdio 示例 | 无内置 broker、TCP 客户端、SASL、TLS、持久 outbox、自动重连、定时器或自动重试 |
moon build --target native --deny-warn
npm ci --ignore-scripts --no-audit --no-fund
npm run interop
moon run cmd/main --target native -- value INPUT.bin NEW_OUTPUT.bin
moon run cmd/main --target native -- message INPUT.bin NEW_OUTPUT.bin
moon run cmd/main --target native -- frames INPUT.bin NEW_OUTPUT.binpub suberror AmqpError {
Invalid(String, Int)
Unsupported(String)
Limit(String)
State(String)
} derive(Debug)pub struct Endpoint {
// private fields
}pub(all) struct Frame {
channel : Int
performative : Performative?
payload : Bytes
extended_header : Bytes
}pub struct FrameStream {
// private fields
}pub struct Message {
// private fields
}fn Message::expiry_status(self : Message, acquired_at : Int64, now : Int64) -> ExpiryStatus raise AmqpErrorpub struct Performative {
// private fields
}fn Performative::new(code : Int, fields : Array[Value], limits? : Limits) -> Performative raise AmqpErrorpub struct SessionWindow {
// private fields
}fn SessionWindow::establish(self : SessionWindow, next_incoming : UInt, peer_incoming : UInt, peer_outgoing : UInt) -> Unit raise AmqpErrorfn SessionWindow::new(incoming : UInt, outgoing : UInt, next_outgoing? : UInt) -> SessionWindow raise AmqpErrorfn SessionWindow::refresh(self : SessionWindow, incoming : UInt, outgoing : UInt) -> Unit raise AmqpErrorfn SessionWindow::update_peer(self : SessionWindow, next_incoming : UInt?, incoming : UInt, next_outgoing : UInt, outgoing : UInt) -> Unit raise AmqpErrorpub(all) enum Value {
Null
Boolean(Bool)
UByte(Int)
UShort(Int)
UInt(UInt)
ULong(UInt64)
ByteValue(Int)
Short(Int)
IntValue(Int)
Long(Int64)
FloatValue(Float)
DoubleValue(Double)
Decimal32(Bytes)
Decimal64(Bytes)
Decimal128(Bytes)
Character(UInt)
Timestamp(Int64)
Uuid(Bytes)
Binary(Bytes)
Text(String)
Symbol(String)
List(Array[Value])
MapValue(Array[(Value, Value)])
ArrayValue(Int, Value?, Array[Value])
Described(Value, Value)
} derive(Debug)Install
Download zipAMQP 1.0 typed wire codec and bounded sans-I/O messaging state machines