Queue-overflow-policy
QueueOverflowPolicy is the public enum that defines what a synchronous queue should do when it reaches max_pending. It is a direct alias to the queue model enum used by both QueuedSink and QueueConfig.
Interface
pub type QueueOverflowPolicy = @utils.QueueOverflowPolicyoutput
QueueOverflowPolicy- Public synchronous queue overflow enum with the variantsDropNewestandDropOldest.
Explanation
Detailed rules explaining key parameters and behaviors
- This is a type alias, not a separate policy wrapper.
QueueOverflowPolicy::DropNewestkeeps the existing queued records and drops the incoming one when the queue is full.QueueOverflowPolicy::DropOldestremoves one pending record and enqueues the new record instead.- The same enum is used by code-side queue composition through
queued_sink(...)and config-driven queue composition throughQueueConfig::new(...).
How to Use
Here are some specific examples provided.
When Need A Bounded Queue That Prefers Older Pending Records
When the oldest pending records should be preserved and new bursts can be dropped:
let sink = queued_sink(console_sink(), max_pending=32, overflow=QueueOverflowPolicy::DropNewest)In this example, new records are discarded once the queue is full.
When Need To Prefer Fresh Records Over Old Pending Work
When backlog should make room for newer records:
let queue = QueueConfig::new(32, overflow=QueueOverflowPolicy::DropOldest)In this example, the oldest pending record is removed when the queue overflows.
Error Case
e.g.:
If a queue is unbounded or never reaches capacity, the overflow policy has no effect.
If parsed JSON uses unsupported overflow text, config parsing raises
ConfigError.
Notes
This policy belongs to synchronous queue wrappers, not
bitlogger_async.Use
AsyncOverflowPolicyfor the async logger queue behavior.