17 releases

0.11.0-alpha.17 Sep 20, 2024
0.11.0-alpha.16 Sep 11, 2024
0.11.0-alpha.13 Aug 29, 2024
0.11.0-alpha.7 Jul 31, 2024
0.11.0-alpha.6 Jun 28, 2024

#348 in Debugging

Download history 654/week @ 2024-06-07 73/week @ 2024-06-14 2/week @ 2024-06-21 187/week @ 2024-06-28 57/week @ 2024-07-05 107/week @ 2024-07-26 22/week @ 2024-08-02 89/week @ 2024-08-09 174/week @ 2024-08-16 488/week @ 2024-08-23 123/week @ 2024-08-30 410/week @ 2024-09-06 224/week @ 2024-09-13 199/week @ 2024-09-20

1,109 downloads per month
Used in 2 crates

MIT/Apache

195KB
4.5K SLoC

emit_batcher

batcher

Current docs

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.

Status

This library is still experimental, so its API may change.

Dependencies

~0.7–7MB
~48K SLoC