[][src]Struct segments::MemoryLog

pub struct MemoryLog<T> { /* fields omitted */ }

Log is an inmemory commitlog (per topic) which splits data in segments. It drops the oldest segment when retention policies are crossed. Each segment is identified by base offset and a new segment is created when ever current segment crosses disk limit

Implementations

impl<T: Debug + Clone> MemoryLog<T>[src]

pub fn new(max_segment_size: usize, max_segments: usize) -> MemoryLog<T>[src]

Create a new log

pub fn append(&mut self, size: usize, record: T) -> (u64, u64)[src]

Appends this record to the tail and returns the offset of this append. When the current segment is full, this also create a new segment and writes the record to it. This function also handles retention by removing head segment

pub fn next_offset(&self) -> (u64, u64)[src]

pub fn read(&mut self, base_offset: u64, offset: usize) -> Option<T>[src]

Read a record from correct segment

pub fn readv(
    &mut self,
    segment: u64,
    offset: u64
) -> (Option<u64>, u64, u64, Vec<T>)
[src]

Reads multiple packets from the disk and returns base offset and offset of the next log. 1st return = Done status is used by the caller to jump to next segment. When data of deleted segment is asked, returns data of the current head Note: Base offset is used to be able to pull directly from correct segment instead of Note: Uses an explicit index to identify correct segment. Kafka clients just use absolute Note: This method also returns full segment data when requested data is not of active segment. Set your max_segment size keeping tail latencies of all the concurrent connections mind (some runtimes support internal preemption using await points)

Auto Trait Implementations

impl<T> RefUnwindSafe for MemoryLog<T> where
    T: RefUnwindSafe

impl<T> Send for MemoryLog<T> where
    T: Send

impl<T> Sync for MemoryLog<T> where
    T: Sync

impl<T> Unpin for MemoryLog<T> where
    T: Unpin

impl<T> UnwindSafe for MemoryLog<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.