pub struct AsyncPoolSink { /* private fields */ }
Expand description
A combined sink, logging and flushing asynchronously (thread-pool-based).
Expensive operations (such as log
and flush
) on asynchronous sinks will
be performed asynchronously on other threads.
Since there is no waiting, errors that occur while performing asynchronous operations will not be returned to the upper level, and instead the error handler of the sink will be called.
Users should only use asynchronous combined sinks to wrap actual sinks that require a long time for operations (e.g., file sinks that are frequently flushed, sinks involving networks), otherwise they will not get a performance boost or even worse.
Since the thread pool has a capacity limit, the queue may be full in some cases. When users encounter this situation, they have the following options:
-
Adjust to a larger capacity via
ThreadPoolBuilder::capacity
. -
Adjust the overflow policy via
AsyncPoolSinkBuilder::overflow_policy
. -
Set up an error handler on asynchronous combined sinks via
AsyncPoolSinkBuilder::error_handler
. The handler will be called when a record is dropped or an operation has failed.
§Note
Errors that occur in log
and flush
will not be returned directly,
instead the error handler will be called.
§Examples
See ./examples directory.
Implementations§
Source§impl AsyncPoolSink
impl AsyncPoolSink
Sourcepub fn builder() -> AsyncPoolSinkBuilder
Available on crate feature multi-thread
only.
pub fn builder() -> AsyncPoolSinkBuilder
multi-thread
only.Constructs a builder of AsyncPoolSink
with default parameters:
Parameter | Default Value |
---|---|
level_filter | All |
error_handler | ErrorHandler::default() |
overflow_policy | Block |
thread_pool | internal shared default thread pool |
Trait Implementations§
Source§impl Sink for AsyncPoolSink
Available on crate feature multi-thread
only.
impl Sink for AsyncPoolSink
multi-thread
only.Source§impl SinkPropAccess for AsyncPoolSink
Available on crate feature multi-thread
only.
impl SinkPropAccess for AsyncPoolSink
multi-thread
only.Source§fn set_formatter(&self, formatter: Box<dyn Formatter>)
fn set_formatter(&self, formatter: Box<dyn Formatter>)
For AsyncPoolSink
, the function performs the same call to all
internal sinks.