v1.0.0 — Stable API #1
jamesgober
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
throttle-net v1.0.0 — Stable
The outbound throttling and resilience library is stable. After the 0.x series built and hardened it, v1.0.0 freezes the public API until 2.0. One library replaces the four you assemble today — a token bucket, a backoff loop, a circuit breaker, and per-provider header parsing — and adds the parts nobody else ships: multi-dimensional cost-aware limits and adaptive throttling. No functional change from 0.9.0; this release is the stability commitment.
What is throttle-net?
Where
rate-netprotects your service from being overwhelmed (inbound), throttle-net protects your service from overwhelming the downstreams it calls — and from being banned by them. The defining operation is to wait for capacity, not to reject: you pace your own outbound work rather than dropping someone else's request.The common case is one builder and one
acquire().await?:The hard cases — LLM token budgets, per-tenant quotas, adaptive backpressure — are first-class.
The stable surface
Everything below is frozen until 2.0.
Throttle] token bucket (lock-free, one atomic compare-and-swap per acquire) and the exact [SlidingWindowLog] (no boundary burst), each with a waiting, cost-awareacquireand non-blockingtry_acquire/peek.Hybrid] (must pass all), [MultiLimiter] (multi-dimensional cost-aware budgets), [PerKey] (independent per-key state with bounded memory), and [Layered] (global / per-key / per-endpoint scopes) — all with peek-then-commit correctness, so a request never spends in one limiter when another would block it.Backoff] (constant / linear / exponential, with full / equal / decorrelated jitter) and [Retry] with per-error classification andRetry-Afterhonoring.CircuitBreaker] that wraps any limiter and fails fast without consuming it, and a bounded, deadline-aware, priority [Queue].AdaptiveLimiter] that discovers the right in-flight limit from outcome feedback (AIMD or Vegas), never exceeding the hard ceiling.Limitertrait — the Tier-3 extension seam; every algorithm and composite is oneLimiter.The tiered design holds: Tier-1 is the whole common case in a couple of calls, Tier-2 the builders for tuning, Tier-3 the trait seam for custom backends.
Runtime and platform
no_std— withstdoff, the pure algorithm core ([Backoff], [Jitter], [Decision]) compiles without the standard library.How it is held correct
The defining invariants are tested, not assumed:
[floor, ceiling].loommodel check that exhaustively explores the adaptive limiter's lock-free slot accounting — no over-admission, no lost slots — under arbitrary thread interleavings.Retry-Afterand provider-header parsers never panic on arbitrary input, checked both bycargo-fuzztargets and an always-on deterministic smoke suite. (This caught two real integer-overflow panics during 0.9, both fixed.)unsafe— the crate is#![forbid(unsafe_code)].try_acquireis ~27 ns (target < 50 ns), benchmarked head-to-head withgovernor, with a contention sweep at 1 / 4 / 16 / 64 acquirers.Changes since 0.9.0
serdefeature flag (it pulled the dependency but wired up noSerialize/Deserialize). Serializable configs may return post-1.0 as an additive feature with a designed, documented representation.Breaking changes
None from 0.9.0. The only removal is the no-op
serdefeature flag, which had no functional effect.After 1.0
Backward-compatible additions under consideration (not yet shipped):
serde), with a designed on-disk representation.throttle-net-tower,throttle-net-reqwest).Verification
Run on Windows x86_64, Rust stable; the same commands run in CI on Linux, macOS, and Windows across stable and MSRV 1.85, with dedicated jobs for the smol +
no_stdmatrix, theloommodel check, and the fuzz smoke run:All green.
Installation
MSRV: Rust 1.85.
Documentation
Thanks
throttle-net builds on the first-party stack:
better-bucket(token-bucket accounting),clock-lib(mockable time),error-forge(domain errors), andahash(DoS-resistant shard hashing). It is the outbound companion torate-net.Changelog:
CHANGELOG.md.This discussion was created from the release v1.0.0 — Stable API.
Beta Was this translation helpful? Give feedback.
All reactions