目录

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:

  • 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?
  • What happened during a burst of requests?

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

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.

关于
270.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号