LogBatch

Struct LogBatch 

Source
pub struct LogBatch { /* private fields */ }
Expand description

A batch of log records yielded by the tailer stream.

Each record is a parsed JSON value. A batch may contain records from multiple segment files when a file boundary is crossed while filling the batch.

Call LogBatch::commit after processing the batch to advance the checkpoint. If commit is not called the checkpoint remains at its prior position, so the records in this batch will be re-read on the next run.

Implementations§

Source§

impl LogBatch

Source

pub fn new() -> Self

Create a new empty batch with a default consumer name.

Source

pub fn with_consumer_name(name: String) -> Self

Create a new empty batch for the named consumer.

Source

pub fn consumer_name(&self) -> &str

The name of the consumer this batch belongs to.

Source

pub fn commit(&mut self) -> Result<()>

Advance the checkpoint to the end of this batch.

This confirms that the caller has successfully processed the batch. If checkpointing is not enabled, or if this batch has already been committed, this is a no-op.

Source

pub fn len(&self) -> usize

The number of records in this batch.

Source

pub fn is_empty(&self) -> bool

Whether the batch is empty.

Source

pub fn records(&self) -> &[Value]

The parsed JSON records.

Source

pub fn file_names(&self) -> &[Utf8PathBuf]

The list of unique segment file names that contributed records to this batch.

Source

pub fn file_name_for_line(&self, index: usize) -> &Utf8PathBuf

Return the segment file name for the record at index.

Source

pub fn byte_offset_for_line(&self, index: usize) -> u64

Return the byte offset in the decompressed stream for the record at index.

Trait Implementations§

Source§

impl AsRef<[Value]> for LogBatch

Source§

fn as_ref(&self) -> &[Value]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Default for LogBatch

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> MaybeSend for T
where T: Send,