NATS-compatible server with JetStream, written in MoonBit
Status: core NATS server is working. A client can connect, authenticate, PING/PONG, SUB, PUB/HPUB, and receive MSG/HMSG, including wildcard and queue-group subscriptions. The server enforces payload/control line/connection limits, has bounded per-connection outboxes with slow-consumer disconnects, implements no-responders 503, serves /varz, /connz, /subsz and /healthz, and exposes an embedded ServerHandle API. JetStream and KV are the next milestones. The plan and scope are tracked in docs/acceptance.md.
| Area | v1 |
|---|---|
| Core NATS | protocol listed above, headers, wildcards, queue groups, auth, limits, no-responders, monitoring |
| Embedded | ServerHandle + start / serve / stop |
| JetStream | single-node streams, retention, dedupe, push/pull consumers, ACK/NAK/WPI/TERM, KV (next) |
| Out of scope | clustering/Raft, leaf nodes, gateways, JWT/nkey, multi-tenancy, mirrors/sources, object store, encryption at rest |
moon check --deny-warn
moon test --target wasm-gc # pure core, no native toolchain required
moon test --target native # protocol, auth and TCP integration tests
moon run cmd/moonnatsd # listens on 127.0.0.1:4222moon run cmd/moonnatsd -- --token secret --monitor-port 8222
curl -s http://127.0.0.1:8222/varz
nats -s nats://127.0.0.1:4222 --auth-token secret pub hello worldlet handle = @natsd.start(config) // config.port = 0 for an ephemeral port
@async.with_task_group(group => {
group.spawn_bg(() => handle.serve())
let url = handle.url()
// connect a client to url
handle.stop()
})src/core pure protocol model, header/CONNECT parsing, subject trie, stats
src/server native listener/connection runtime, auth, monitoring, embedded handle
src/store WAL/block storage and recovery (planned)
src/jetstream stream/consumer state machines (planned)
src/kv KV facade over JetStream (planned)
src/cli argument parsing and command lineInstall
Download zipNATS-compatible server with JetStream, written in MoonBit