pub struct FileLog { /* private fields */ }Expand description
A commit log implementation that uses the file system as its backing store.
Considerations:
- Partition values cannot be non-zero.
- The number of subscriptions of a topic will translate to the number of tasks that are spawned, along with their associated resources.
- 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
impl FileLog
Sourcepub fn new<P>(root_path: P) -> Self
pub fn new<P>(root_path: P) -> Self
Construct a new file log that will also spawn a task for each topic being produced.
Sourcepub 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
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
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.
Sourcepub fn close_topic(&mut self, topic: &Topic)
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.
Sourcepub async fn register_compaction<CS>(
&mut self,
topic: Topic,
compaction_strategy: CS,
) -> Result<(), CompactionRegistrationError>
pub async fn register_compaction<CS>( &mut self, topic: Topic, compaction_strategy: CS, ) -> Result<(), CompactionRegistrationError>
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.
Sourcepub fn unregister_compaction(&mut self, topic: &Topic)
pub fn unregister_compaction(&mut self, topic: &Topic)
Unregister compaction for a given topic