[−][src]Struct segments::MemoryLog
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]
&mut self,
segment: u64,
offset: u64
) -> (Option<u64>, u64, u64, Vec<T>)
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,
T: RefUnwindSafe,
impl<T> Send for MemoryLog<T> where
T: Send,
T: Send,
impl<T> Sync for MemoryLog<T> where
T: Sync,
T: Sync,
impl<T> Unpin for MemoryLog<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for MemoryLog<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,