41 releases (9 stable)
new 1.5.0 | Mar 27, 2025 |
---|---|
1.0.1 | Feb 25, 2025 |
0.11.10 | Feb 11, 2025 |
0.11.0-alpha.21 | Oct 21, 2024 |
0.11.0-alpha.7 | Jul 31, 2024 |
#1042 in Debugging
1,773 downloads per month
Used in 2 crates
3MB
8K
SLoC
emit_batcher
Infrastructure for emitting diagnostic events in the background.
lib.rs
:
Infrastructure for emitting diagnostic events in the background.
This library implements a channel that can be used to spawn background workers on a dedicated thread or tokio
runtime. The channel implements:
- Batching: Events written to the channel are processed by the worker in batches rather than one-at-a-time.
- Retries with backoff: If the worker fails or panics then the batch can be retried up to some number of times, with backoff applied between retries. The worker can decide how much of a batch needs to be retried.
- Maximum size management: If the worker can't keep up then the channel truncates to avoid runaway memory use. The alternative would be to apply backpressure, but that would affect system availability so isn't suitable for diagnostics.
- Flushing: Callers can ask the worker to signal when all diagnostic events in the channel at the point they called are processed. This can be used for auditing and flushing on shutdown.
WebAssembly
This library can be used on the wasm32-unknown-unknown
target by enabling the web
Cargo feature.
Instead of spawning background threads to run the batching receiver, it will instead spawn a fire-and-forget promise.
Blocking functions like blocking_send
and blocking_flush
are not available, but asynchronous send
and flush
variants are.
Dependencies
~0.7–8.5MB
~74K SLoC