FileLog

Struct FileLog 

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

A commit log implementation that uses the file system as its backing store.

Considerations:

  1. Partition values cannot be non-zero.
  2. The number of subscriptions of a topic will translate to the number of tasks that are spawned, along with their associated resources.
  3. Only one process can produce to a specific topic. There is no process-wide locking considered. Multiple processes can read a topic though.

Implementations§

Source§

impl FileLog

Source

pub fn new<P>(root_path: P) -> Self
where P: Into<PathBuf>,

Construct a new file log that will also spawn a task for each topic being produced.

Source

pub fn with_config<P>( root_path: P, compaction_threshold_size: u64, read_buffer_size: usize, compaction_write_buffer_size: usize, write_buffer_size: usize, max_record_size: usize, ) -> Self
where P: Into<PathBuf>,

Construct a new file log that will also spawn a task for each topic being produced. The compaction_threshold_size is the size of the active file that the compactor looks at before deciding to perform a compaction (in bytes). This typically equates to the blocksize on disk i.e. 64KB for flash based storage. 64KB is still small enough that scans over a topic are relatively fast, working on the principle of having roughly 2,000 records. We also require a read and write buffer sizes to reduce system calls. When writing, either the buffer reaches capacity or a flush of the buffer occurs in the absence of another write to perform.

Source

pub fn close_topic(&mut self, topic: &Topic)

Frees resources associated with a topic, but not any associated compaction. Invoking the method is benign in that if consuming or producing occurs on this post closing, resources will be re-established.

Source

pub async fn register_compaction<CS>( &mut self, topic: Topic, compaction_strategy: CS, ) -> Result<(), CompactionRegistrationError>
where CS: CompactionStrategy + Send + Sync + 'static,

Register compaction for a given topic. Any previously registered compaction is replaced. A new task for compaction will be created in the background.

Compaction’s memory can be controlled somewhat through compaction_write_buffer_size when creating this file commit log. This buffer size is selected to minimize writing to flash and will be allocated once per topic compaction registered here.

Source

pub fn unregister_compaction(&mut self, topic: &Topic)

Unregister compaction for a given topic

Trait Implementations§

Source§

impl Clone for FileLog

Source§

fn clone(&self) -> FileLog

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CommitLog for FileLog

Source§

fn offsets<'life0, 'async_trait>( &'life0 self, topic: Topic, _partition: Partition, ) -> Pin<Box<dyn Future<Output = Option<PartitionOffsets>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve the current offsets of a topic if they are present.
Source§

fn produce<'life0, 'async_trait>( &'life0 self, record: ProducerRecord, ) -> Pin<Box<dyn Future<Output = Result<ProducedOffset, ProducerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Publish a record and return the offset that was assigned.
Source§

fn scoped_subscribe<'a>( &'a self, _consumer_group_name: &str, offsets: Vec<ConsumerOffset>, subscriptions: Vec<Subscription>, idle_timeout: Option<Duration>, ) -> Pin<Box<dyn Stream<Item = ConsumerRecord> + Send + 'a>>

Subscribe to one or more topics for a given consumer group having committed zero or more topics. The records are streamed back indefinitely unless an idle timeout argument is provided. In the case of an idle timeout, if no record is received within that period, None is returned to end the stream.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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

Source§

fn vzip(self) -> V