Struct carboncopy_tokio::BufSink [−][src]
pub struct BufSink<T: AsyncWriteExt + Unpin + Send + 'static> { /* fields omitted */ }
Expand description
A sink with memory buffer and periodic flusher built with Tokio facilities so it is suitable for binaries relying on the Tokio executor. It can also be used by async-blind library clients since the Sink trait offers blocking API.
Its mutable interior is guarded by Arc<Mutex<...>>
.
Implementations
impl<T: AsyncWriteExt + Unpin + Send + 'static> BufSink<T>
[src]
impl<T: AsyncWriteExt + Unpin + Send + 'static> BufSink<T>
[src]pub fn new(opts: SinkOptions<T>) -> Self
[src]
pub fn new(opts: SinkOptions<T>) -> Self
[src]At the same time as the instantiation, a flusher task is spawned in the background whose job is to flush after the buffer overflows or a set timeout has elapsed (whichever happens first).
The flusher task will terminate when the instance is dropped.
pub async fn flush(&self) -> Result<usize>
[src]
pub async fn flush(&self) -> Result<usize>
[src]Attempts to manually flush the underlying buffer to Stdout.
pub async fn backlogged(&self) -> bool
[src]
pub async fn backlogged(&self) -> bool
[src]Checks if buffer flushing is being backlogged (not necessarily by errors).
pub fn last_flush_err(&self) -> Option<Arc<Error>>
[src]
pub fn last_flush_err(&self) -> Option<Arc<Error>>
[src]Checks if the flusher has just encountered an error. Only use this function to check for long running errors. A temporary error could already be cleared by retries by the time you call this function.
A bufferless sink will always return None.
Trait Implementations
impl<T: AsyncWriteExt + Unpin + Send + 'static> Sink for BufSink<T>
[src]
impl<T: AsyncWriteExt + Unpin + Send + 'static> Sink for BufSink<T>
[src]fn sink_blocking(&self, entry: String) -> Result<()>
[src]
fn sink_blocking(&self, entry: String) -> Result<()>
[src]Sinks a log entry and blocks the current thread while waiting for I/O completion for
async blind callers that want to wait for acknowledgment.
Example implementation is block_on(/* I/O logic */)
. Refer to the block_on
API offered by tokio, async-std, etc. Read more