MoonBackpressureKit is a MoonBit foundation library for backpressure, token
bucket admission, credit-window control, AIMD adaptation, and pressure reports.
What It Solves
MoonBackpressureKit helps MoonBit programs make overload decisions before a
queue, worker pool, or producer/consumer pipeline collapses:
Should incoming work be admitted, delayed, or dropped?
Is the local queue open, warm, hot, or saturated?
How many in-flight credits are still available?
How should a concurrency window shrink after overload?
TokenBucket: rate-oriented admission with logical tick refill.
CreditWindow: bounded outstanding work control.
AimdController: additive increase and multiplicative decrease.
FlowPolicy: combines buffer, token bucket, and credit guards.
PressureStats: tracks admitted, delayed, and dropped work.
to_json: stable summaries for demos, tests, and diagnostics.
Minimal Example
let policy = worker_queue_policy()
let (next, stats) = run_burst(policy, sample_burst())
println(next.buffer.to_json())
println(stats.to_json())
Run
moon check --target all
moon test --target wasm
moon test --target wasm-gc
moon run cmd/main
Scenarios
Worker queues that need to slow producers before memory pressure rises.
API gateway admission checks that combine rate and in-flight limits.
ETL pipelines that need predictable overload behavior during bursts.
RPC clients that adapt concurrency windows after downstream overload.
Simulators and teaching demos for backpressure and flow-control policies.
Project Boundaries
MoonBackpressureKit is not an async runtime, scheduler, message broker, RPC
framework, quota system, or SLO evaluator. It does not own threads, sockets,
timers, or persistence. Callers provide logical ticks and workload costs; the
library provides deterministic flow-control decisions.
Repository
GitHub and GitLink are mirrors of the same competition project. The repository
includes source code, tests, CI, architecture notes, related-work notes,
acceptance notes, and a public application summary.
MoonBackpressureKit
MoonBackpressureKit is a MoonBit foundation library for backpressure, token bucket admission, credit-window control, AIMD adaptation, and pressure reports.
What It Solves
MoonBackpressureKit helps MoonBit programs make overload decisions before a queue, worker pool, or producer/consumer pipeline collapses:
Core API
BufferState: queue capacity, queued work, in-flight work, usage percent.TokenBucket: rate-oriented admission with logical tick refill.CreditWindow: bounded outstanding work control.AimdController: additive increase and multiplicative decrease.FlowPolicy: combines buffer, token bucket, and credit guards.PressureStats: tracks admitted, delayed, and dropped work.to_json: stable summaries for demos, tests, and diagnostics.Minimal Example
Run
Scenarios
Project Boundaries
MoonBackpressureKit is not an async runtime, scheduler, message broker, RPC framework, quota system, or SLO evaluator. It does not own threads, sockets, timers, or persistence. Callers provide logical ticks and workload costs; the library provides deterministic flow-control decisions.
Repository
GitHub and GitLink are mirrors of the same competition project. The repository includes source code, tests, CI, architecture notes, related-work notes, acceptance notes, and a public application summary.