pub struct BatchProcessor { /* private fields */ }Expand description
Generic background batcher: queues records and exports them from a tokio task.
Implementations§
Source§impl BatchProcessor
impl BatchProcessor
Sourcepub fn new(exporter: Arc<dyn LogExporter>, opts: BatchOptions) -> Result<Self>
pub fn new(exporter: Arc<dyn LogExporter>, opts: BatchOptions) -> Result<Self>
Starts a processor; must be called inside a tokio runtime.
Sourcepub fn options(&self) -> &BatchOptions
pub fn options(&self) -> &BatchOptions
Options in use.
Sourcepub fn add(&self, record: LogRecord) -> bool
pub fn add(&self, record: LogRecord) -> bool
Enqueues a record; returns false when it was dropped. Never blocks unless the policy
is DropPolicy::Block.
Sourcepub async fn add_async(&self, record: LogRecord) -> bool
pub async fn add_async(&self, record: LogRecord) -> bool
Like add, but waits asynchronously for room under DropPolicy::Block.
Sourcepub async fn flush(&self, timeout: Option<Duration>) -> Result<()>
pub async fn flush(&self, timeout: Option<Duration>) -> Result<()>
Exports everything queued at the time of the call. None waits without a limit (every
export attempt is still bounded by export_timeout); on expiry returns TIMEOUT.
Sourcepub async fn shutdown(&self, timeout: Option<Duration>) -> Result<()>
pub async fn shutdown(&self, timeout: Option<Duration>) -> Result<()>
Drains the queue, stops the worker and shuts the exporter down. Idempotent; later
add calls drop records with reason shutdown. When timeout expires the
remaining records are dropped and TIMEOUT is returned.
Sourcepub fn stats(&self) -> BatchStats
pub fn stats(&self) -> BatchStats
Current counters.
Trait Implementations§
Source§impl Debug for BatchProcessor
impl Debug for BatchProcessor
Auto Trait Implementations§
impl !Freeze for BatchProcessor
impl !RefUnwindSafe for BatchProcessor
impl !UnwindSafe for BatchProcessor
impl Forget for BatchProcessor
impl Move for BatchProcessor
impl Send for BatchProcessor
impl Sync for BatchProcessor
impl Unpin for BatchProcessor
impl UnsafeUnpin for BatchProcessor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more