Skip to main content

Module backpressure

Module backpressure 

Source
Expand description

Backpressure: BytePermits

Byte-based flow control for write pumps.

Design principle:

  • Backpressure scales with bytes, not message count
  • One giant message should not starve other connections
  • Pluggable: NoOp (default) → Semaphore → dynamic policy

Usage:

let permits = SemaphorePermits::new(10 * 1024 * 1024); // 10MB limit
let permit = permits.acquire(n_bytes).await;
writer.write(buf).await;
drop(permit); // releases automatically

Structs§

NoOpPermits
No-op implementation (Phase 0).
Permit
RAII permit guard.
SemaphorePermits
Semaphore-based backpressure implementation.

Traits§

BytePermits
Backpressure permit trait.