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.3.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 映射 | 最多 64 个本地会话,默认 16;启用 recoverable 后支持在原会话或新会话重挂。动态节点、持久化终端及过滤扩展仍受限 |
| 收发 | link credit、session window、自动发送分片、接收组装/aborted、三种 sender settle mode、receiver First/Second、link 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
}fn Endpoint::attach(self : Endpoint, name : String, sender : Bool, address : String, handle? : UInt, receiver_mode? : ReceiverSettleMode, recoverable? : Bool, channel? : Int) -> UInt raise AmqpErrorfn Endpoint::new(container : String, channel? : Int, window? : UInt, max_sessions? : Int, idle_advertised_ms? : UInt, recovery? : RecoveryStore?, limits? : Limits) -> Endpoint raise AmqpErrorfn Endpoint::recovery_status(self : Endpoint, handle : UInt, channel? : Int) -> RecoveryStatus raise AmqpErrorfn Endpoint::suspend_readiness(self : Endpoint, handle : UInt, channel? : Int) -> SuspendReadiness raise AmqpErrorfn Endpoint::suspended_links(self : Endpoint, channel? : Int) -> Array[SuspendedLink] raise AmqpErrorpub(all) struct EndpointDiagnostic {
closed : Bool
failed : Bool
session_ready : Bool
queued_bytes : Int
partial_bytes : Int
queued_events : Int
links : Array[LinkDiagnostic]
}pub enum Event {
RemoteOpen(String)
SessionReady
LinkReady(UInt, String, Bool)
Credit(UInt, UInt)
Received(Delivery)
Settled(UInt, Outcome)
PeerSettled(UInt)
UnsettledLost(UInt, Bool)
Aborted(UInt, UInt)
Detached(UInt)
LinkSuspended(String, UInt)
RecoverySettled(UInt, Bytes)
DeliveryRebound(UInt, UInt, Bytes)
RecoveryStoreFull(String)
SessionEnded(Value)
RemoteClosed(Value)
SessionEvent(Int, Event)
DrainRequested(UInt, UInt)
DrainCompleted(UInt, UInt)
}pub(all) struct Frame {
channel : Int
performative : Performative?
payload : Bytes
extended_header : Bytes
}pub struct FrameStream {
// private fields
}pub(all) struct LinkDiagnostic {
name : String
address : String
handle : UInt
remote_handle : UInt?
sender : Bool
ready : Bool
closed : Bool
credit : UInt
outgoing_unsettled : Int
incoming_unsettled : Int
receiving_fragment : Bool
}pub struct Message {
// private fields
}fn Message::expiry_status(self : Message, acquired_at : Int64, now : Int64) -> ExpiryStatus raise AmqpErrorpub(all) enum Outcome {
Accepted
Rejected(String, String?)
RejectedWithoutError
Released
Modified(Bool, Bool)
ModifiedWithAnnotations(Bool, Bool, OutcomeAnnotations)
} derive(Eq, Debug)impl Eq for OutcomeAnnotationspub struct Performative {
// private fields
}fn Performative::new(code : Int, fields : Array[Value], limits? : Limits) -> Performative raise AmqpErrorpub struct RecoveryStore {
// private fields
}fn RecoveryStore::forget(self : RecoveryStore, local_container : String, remote : String, name : String, sender : Bool) -> Boolpub(all) struct SessionDiagnostic {
channel : Int
remote_channel : Int?
ending : Bool
next_incoming : UInt
next_outgoing : UInt
incoming_window : UInt
outgoing_window : UInt
peer_incoming_window : UInt
outgoing_unsettled : Int
incoming_unsettled : Int
awaiting_sender_confirmation : Int
links : Array[LinkDiagnostic]
}pub 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