2.4 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| async-logger-config | api | async | 20260512 | Create the queue, batching, linger, and flush policy config used by async loggers. |
|
Async-logger-config
Create an AsyncLoggerConfig value describing queue capacity, overflow behavior, batching size, linger timing, and flush policy for async logger construction.
Interface
pub fn AsyncLoggerConfig::new(
max_pending~ : Int = 0,
overflow~ : AsyncOverflowPolicy = AsyncOverflowPolicy::Blocking,
max_batch~ : Int = 1,
linger_ms~ : Int = 0,
flush~ : AsyncFlushPolicy = AsyncFlushPolicy::Never,
) -> AsyncLoggerConfig {}
input
max_pending : Int- Maximum queued records.overflow : AsyncOverflowPolicy- Queue overflow strategy.max_batch : Int- Maximum records drained per batch.linger_ms : Int- Optional wait window for batch accumulation.flush : AsyncFlushPolicy- Flush behavior for batch/shutdown phases.
output
AsyncLoggerConfig- Async runtime config object used byasync_logger(...)or async build helpers.
Explanation
Detailed rules explaining key parameters and behaviors
max_batch <= 1is normalized to1.linger_ms < 0is normalized to0.overflowandflushdefine the most important queue/runtime behavior tradeoffs.- This type is used directly by
async_logger(...)and embedded inAsyncLoggerBuildConfig.
How to Use
Here are some specific examples provided.
When Tune Async Queue Backlog And Batch Size
When async behavior should be explicit in code:
let config = AsyncLoggerConfig::new(
max_pending=128,
overflow=AsyncOverflowPolicy::DropOldest,
max_batch=8,
linger_ms=10,
flush=AsyncFlushPolicy::Batch,
)
In this example, queue pressure, batch size, and flush timing are configured together.
When Export Async Config
When async policy should be serialized or logged:
println(stringify_async_logger_config(AsyncLoggerConfig::new(max_pending=8)))
In this example, the config becomes a stable JSON payload.
Error Case
e.g.:
-
If
max_batchis set to0or below, runtime config normalizes it to1. -
If
linger_msis negative, it is normalized to0.
Notes
-
This type controls async runtime behavior, not synchronous queue wrapping.
-
Prefer explicit values for production services so overflow and flush semantics are visible.